MadifiedJoin Date: 2011-04-19 Post Count: 5292 |
So in some games when you mouse over a part or a tool, you can press E to pick it up. How would I make a gui pop up when you mouseover a tool/part and how would you make it so when you press E while also mouse overd to pick it up and put it in the backpack. Wiki Links are appreciated as I'm sure this is extremely simple I just haven't done it before. |
|
|
"10 points for best answer"
wtf is this yahoo answers?
y-you monster |
|
MadifiedJoin Date: 2011-04-19 Post Count: 5292 |
No this is not yahoo answers. Please don't ask questions that you know the answer to |
|
|
"Please don't ask questions that you know the answer to"
then dont ask how to do what you asked for.
y-you monster |
|
KryddanJoin Date: 2014-12-12 Post Count: 310 |
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local mouse = player:GetMouse()
local pickup = false
local gui = gui --change to the location of the gui
local uis = game:GetService("UserInputService")
local distance = 20 -- change this to how close the part has to be so you can pick it up.
mouse.Move:connect(function()
if mouse.Target.Name == "part or tool name" and (mouse.Target.Position - character.Torso.Position).magnitude <= distance then
pickup = true
gui.Visible = true
uis.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.E and pickup == true then
mouse.Target:Clone().Parent = player.Backpack
mouse.Target:Destroy()
gui.Visible = false
end
end)
else
pickup = false
gui.Visible = false
end
end) |
|
MadifiedJoin Date: 2011-04-19 Post Count: 5292 |
@iJacob, I was kiiidddinnng, we're all friends here. And thanks for the help everyone |
|
KryddanJoin Date: 2014-12-12 Post Count: 310 |
"thanks for the help everyone"
I was everyone but aight :P |
|
MadifiedJoin Date: 2011-04-19 Post Count: 5292 |
I couldn't remember you're name :P sorry man. Special thanks to the dude with the K in his name ;) |
|
|
yeah,
thanks to that mad guy
y-you monster |
|
MadifiedJoin Date: 2011-04-19 Post Count: 5292 |
Alright guys we need solutions
mouse.Target:Destroy()
that is destroying everything that is under the tool too not just the tool. |
|
KryddanJoin Date: 2014-12-12 Post Count: 310 |
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local mouse = player:GetMouse()
local pickup = false
local gui = gui --change to the location of the gui
local uis = game:GetService("UserInputService")
local distance = 20 -- change this to how close the part has to be so you can pick it up.
local tool
mouse.Move:connect(function()
if mouse.Target.Name == "part or tool name" and (mouse.Target.Position - character.Torso.Position).magnitude <= distance then
pickup = true
gui.Visible = true
uis.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.E and pickup == true then
tool = mouse.Target
tool:Clone().Parent = player.Backpack
tool:Destroy()
tool = nil
pickup = false
gui.Visible = false
end
end)
else
pickup = false
gui.Visible = false
end
end) |
|
|
Kry you didn't need to do that
"Alright guys we need solutions"
Learn 2 script best answer
http://www.roblox.com/unnamed-item?id=385096183 Ready to waste a ton of money of VR tech for Sword Art Online : The Beginning |
|
MadifiedJoin Date: 2011-04-19 Post Count: 5292 |
Haha that would do the same thing, I fixed it using :IsA to check if it was a tool before it removed it. Thanks again Everyone |
|
MadifiedJoin Date: 2011-04-19 Post Count: 5292 |
c9_io is right guys, I need to learn to script. I first need to develop a basic knowledge of rbx.lua before you start tossing me scripts. |
|
KryddanJoin Date: 2014-12-12 Post Count: 310 |
@c9 what are you talking about?? my script works fine without my miss of a if statement. I made a small misstake sorry king |
|
|
No it's fine what you did just that there was a simpler answer
http://www.roblox.com/unnamed-item?id=385096183 Ready to waste a ton of money of VR tech for Sword Art Online : The Beginning |
|
MadifiedJoin Date: 2011-04-19 Post Count: 5292 |
@Kry, I think he was talking about me learning to script instead of you scripting for me. Even though he obviously doesn't come here very often to know that I am always helping people with their scripts. |
|
KryddanJoin Date: 2014-12-12 Post Count: 310 |
ofc there is, I know of a much simpler and more effiecent way but I wrote it like this to get more attention towards less advanced scripters, who probably wouldn't understand the more compley but simpler way.
@mad I am not speaking about you, just so you know |
|