I made a treadmill that works and I made a leaderboard
game.Players.PlayerAdded:Connect(function(plr) local folder = Instance.new("Folder",plr) folder.Name = "leaderstats" local speed = Instance.new("IntValue",folder) speed.Name = "Speed" speed.Value = 1 end)
Then I made this
local speed = game.Players.LocalPlayer.folder.speed local conveyor = game.Workspace.Treadmill.Conveyor conveyor.Touched:Connect(function(hit) if hit ~= nil then while true do if hit.Parent ~= nil then if hit.Parent.Character ~= nil then if hit.Parent.Character.Health ~= 0 then wait(2) speed.Value = speed.Value + 2 end end end end end end)
But it says attempt to index field 'LocalPlayer' (a nil value)
Please help?
I'm not entirely sure, but this might be an easy fix if you make a line at the start of the second script (which is hopefully a local script) that waits for the local player's character to load.
repeat wait() until game.Players.LocalPlayer.Character local speed = game.Players.LocalPlayer.folder.speed local conveyor = game.Workspace.Treadmill.Conveyor conveyor.Touched:Connect(function(hit) if hit ~= nil then while true do if hit.Parent ~= nil then if hit.Parent.Character ~= nil then if hit.Parent.Character.Health ~= 0 then wait(2) speed.Value = speed.Value + 2 end end end end end end)