I'm new to scripting, so I'm just testing out some different types of tools. The tool I'm currently trying to make is a hopperbin that has multiple uses. So far, I've got most of it done, I just need to make it fire a rocket when the user presses the e key. Does anyone mind teaching me how to do this?
The code below is what I have so far:
function onKeyDown(key) key:lower() if key == "e" then end function onSelected(mouse) mouse.KeyDown:connect(onKeyDown) end script.Parent.Selected:connect(onSelected)
Assuming your rocket is a single part in Wokspace named "Engine", or a group of parts welded to it:
function onKeyDown(key) key:lower() if key == "e" then if Workspace.FindFirstChild("Engine") then Workspace.Engine.Velocity = Vector3.new(0,100,0); end end end function onSelected(mouse) mouse.KeyDown:connect(onKeyDown) end script.Parent.Selected:connect(onSelected)
That will fling the part into the air with minimal code, but if you want continuous controllable thrust, look into BodyThrust on the wiki.
Hope this helps!
--Cantos