I have a bike and I set up animations and everything. Now what I want to do is up their stats based on how long they stay on the bike. I had my leaderstats script create the IntValues and everything to store how long they have to stay on the bike to up their stats. Next I made this local script inside the seat on the bike. I can't seem to figure out why it won't work though. Thanks in Advance!
local plr = game.Players.LocalPlayer
local plrwork = workspace:WaitForChild(plr.Name)
local char = plrwork:WaitForChild('Character')
local hum = hum:WaitForChild('Humanoid')
local waittimeFold = plr:WaitForChild("WaitTime")
local waittime = waittimeFold:WaitForChild("WaitTimeSpd")
local loop
local function OnTouch(part)
loop = true
while loop == true do
wait(waittime.Value)
hum.WalkSpeed = hum.WalkSpeed + .2
waittime.Value = waittime.Value + 1
end
end
local function EndTouch()
loop = false
script.Parent.Touched:Connect(OnTouch)
script.Parent.TouchEnded:Connect(EndTouch)

4 comments
At line 09 Does 'part' have to be a variable? idk try making a variable for part if it doesnt work then change it back if you want.
IMO use a regular script if it’s going to be inside the part (bike)
ok
If I make it a a script I can't locate the player