#drone
39 messages · Page 1 of 1 (latest)
and u can do this instead```lua
local User = game:GetService('UserInputService')
local function MoveDrone(key)
if key == Enum.KeyCode.E then
-- script to Move Drone
print("Drone is moving")
end
end
local keyDown = false
User.InputBegan:Connect(function(key)
keyDown = true
MoveDrone(key.KeyCode)
end)
User.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
keyDown = false
end
end)
game:GetService("RunService").Heartbeat:Connect(function()
if keyDown then
MoveDrone(Enum.KeyCode.E)
end
end)```
it prints
holding down the E
for me it does
lol
lol
then
just do lua User.InputBegan:Connect(function(key) if key.KeyCode == Enum.KeyCode.E then keyDown = true MoveDrone(key.KeyCode) end end)
local part = workspace.mover
local User = game:GetService('UserInputService')
local function MoveDrone(key)
if key == Enum.KeyCode.E then
-- script to Move Drone
part.Anchored = false
part.AssemblyLinearVelocity = Vector3.new(0,3,0)
print("Drone is moving")
end
end
local keyDown = false
script.Parent.Activated:Connect(function()
User.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
keyDown = true
end
end)
User.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
keyDown = false
part.Anchored = true
end
end)
game:GetService("RunService").Heartbeat:Connect(function()
if keyDown then
MoveDrone(Enum.KeyCode.E)
end
end)
end)```
local part = workspace.mover
local keyDown = false
local User = game:GetService('UserInputService')
local function MoveDrone(key)
if key == Enum.KeyCode.E then
part.Anchored = false
while keyDown do
part.Velocity = part.Velocity + Vector3.new(0,3,0)
wait()
end
part.Anchored = true
print("Drone stopped moving")
end
end
User.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
keyDown = true
MoveDrone(key.KeyCode)
end
end)
User.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
keyDown = false
end
end)```
since lua game:GetService("RunService").Heartbeat:Connect(function() if keyDown then MoveDrone(Enum.KeyCode.E) end end) end)this updates the MoveDrone while its not listening if false it will set it to true
so it printed when it stopped moving or started
local part = workspace.mover
local User = game:GetService('UserInputService')
local function MoveDrone(key)
if key == Enum.KeyCode.E then
-- script to Move Drone
part.Anchored = false
local velocity = Vector3.new(0, 3, 0)
local angularVelocity = Vector3.new(0, 0, 0)
while wait() do
if part.Position.Y < 0 then
velocity = Vector3.new(0, 0, 0)
angularVelocity = Vector3.new(0, 0, 0)
part.Anchored = true
break
end
part.AssemblyLinearVelocity = velocity
part.AssemblyAngularVelocity = angularVelocity
end
print("Drone is moving")
end
end
local keyDown = false
script.Parent.Activated:Connect(function()
User.InputBegan:Connect(function(key)
keyDown = true
MoveDrone(key.KeyCode)
end)
User.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
keyDown = false
part.Anchored = true
end
end)
end)```
now retry
im fixing the new one to do if keyDown part
Well that sucks my pc turned off so now I have to redo the new edit
But it’s ok
But I’m ok since I’m helping to many people but I don’t care if code looks like crap and doesn’t work first try
Since all people make mistakes even pros
Failure makes pros
I know I’m fixing
I hope it saved before it turned off
local part = workspace.mover
local User = game:GetService('UserInputService')
local function MoveDrone(key)
if key == Enum.KeyCode.E then
-- script to Move Drone
part.Anchored = false
local velocity = Vector3.new(0, 3, 0)
local angularVelocity = Vector3.new(0, 0, 0)
while wait() do
if part.Position.Y < 0 then
velocity = Vector3.new(0, 0, 0)
angularVelocity = Vector3.new(0, 0, 0)
part.Anchored = true
break
end
part.AssemblyLinearVelocity = velocity
part.AssemblyAngularVelocity = angularVelocity
end
print("Drone is moving")
end
end
local keyDown = false
script.Parent.Activated:Connect(function()
User.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
keyDown = true
MoveDrone(key.KeyCode)
end
end)
User.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
keyDown = false
part.Anchored = true
end
end)
game:GetService("RunService").Heartbeat:Connect(function()
if keyDown then
MoveDrone(Enum.KeyCode.E)
end
end)
end)```
now try again
K
thats false, how the hell is it gonna move if its still
this is why i dont look things up til i test
what i mean its better to test first then look it up or ask for help
lol
just add prints to the script instead of print(key.KeyCode)
No like print the stuff in the function to see if it exists
Is it serverside
Why not do a fire event then Connect it to server
** You are now Level 10! **
It’s really not useless since it’s going to make it is if y axis is < 0