Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My script to move a car works, but only once?..

Asked by
lucas4114 607 Moderation Voter
9 years ago

Everything works in my script, the player presses W and the car moves, then I let go of W and it stops. But it only works once, I press W then let go, it works then after I press W for the second time after I let go, and nothing works....


wait(0.1) local Plr = game.Players.LocalPlayer local Mouse = Plr:GetMouse() local Car = game.Workspace:FindFirstChild(""..Plr.Name.."'s_Car") local Speed = 1000000 WIsDown = false Mouse.KeyDown:connect(function(Key) if Key == "w" then if WIsDown == false then WIsDown = true local Force = Instance.new("BodyForce") Force.Parent = Car.Hitbox Force.force = Car.Hitbox.CFrame.lookVector * Speed Force.Name = "WForce" end end end) Mouse.KeyUp:connect(function(Key) if Key == "w" then if WIsDown == true then Car.Hitbox.WForce:Destroy() end end end)

It's in a local script and output says: 10:38:16.793 - WForce is not a valid member of Part 10:38:16.794 - Script 'Players.Player.PlayerGui.WScript', Line 26

1 answer

Log in to vote
1
Answered by
Codebot 85
9 years ago

You never added a WIsDown = false

on line 17 press enter and put WIsDown = false

0
I didn't notice that, lol. ty lucas4114 607 — 9y
0
No problem c: Codebot 85 — 9y
Ad

Answer this question