So currently i am developing a drone. I Made a script that Should move the part up while holding down E.
heres the script:
local Drone = script.Parent -- Yes this will be a drone
local UIS = game:GetService("UserInputService")
local HoldingEkey = false
UIS.InputBegan:Connect(function(InputObject) -- Input began
if (InputObject.KeyCode == Enum.KeyCode.E) then
print("Input Began") -- This print somehow does not print
HoldingEkey = true -- true
while HoldingEkey do
Drone.Position = Drone.Position + Vector3.new(0,0,-0.1,0) -- position
print("should move") -- This does not print either
wait(0.1)
end
end
end)
UIS.InputEnded:Connect(function(InputObject) -- Input ended
if (InputObject.KeyCode == Enum.KeyCode.E) then
HoldingEkey = false
print("Input Ended")
end
end)
somehow It does not work. Theres no errors And i have not anchored it. Am i doing something wrong?
Would respect all help

8 comments
Is it a Normal script or a Local script?
@BestCreativeBoy Its a Normal script. Its parented in The Part
Make sure to use a Local Script when using UserInputService as it is exclusively to Local script. And Local scripts won't work in worksapce.
*workspace
@BestCreativeBoy Ikr but Where should i parent it though
@BestCreativeBoy Where should i parent it?
@BestCreativeBoy Nvm fixed it by parenting it to StarterGui
But, the issue that will occur that it will move only on your screen and not on other player's screen.