everything working fine exept whenever I press E, it only runs once and if I press E again it doesn't move to a random location again.
UIS = game:GetService("UserInputService")
Trans = game.Workspace.Transform
local posi = Vector3.new(math.random(1,50), math.random(1,30), math.random(1,40))
local held = false
UIS.InputBegan:Connect(function(input, GameProccessedEvent)
if input.KeyCode == Enum.KeyCode.E
then
wait()
Trans.Transparency = 0.5
Trans.Position = posi
print ("pressed down E key")
held = true
while held == true
do
wait()
print("holding the key")
end
end
end)
UIS.InputEnded:Connect(function(input, GameProccessedEvent)
if input.KeyCode == Enum.KeyCode.E
then
held = false
end
end)

2 comments
Just add a while loop because the server constantly checks wether the player is pressing e
Add line 1