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....

01wait(0.1)
02 
03local Plr = game.Players.LocalPlayer
04local Mouse = Plr:GetMouse()
05local Car = game.Workspace:FindFirstChild(""..Plr.Name.."'s_Car")
06local Speed = 1000000
07 
08WIsDown = false
09 
10Mouse.KeyDown:connect(function(Key)
11    if Key == "w" then
12        if WIsDown == false then
13            WIsDown = true
14            local Force = Instance.new("BodyForce")
15            Force.Parent = Car.Hitbox
View all 28 lines...

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