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?

3 comments
is it a local script?
Change to server script
Localplayer can only be accessed via the client. You could use remote events.