I am having trouble with this script, and it keeps giving me this error Workspace.TreadmillXP.Script:2: attempt to index local 'Player' (a nil value) Here is the script
local Player = game.Players.LocalPlayer local LeaderStats = Player:WaitForChild("leaderstats") local Level = LeaderStats:WaitForChild("Level")
script.Parent.Touched:connect(function(touch) if touch.Parent:findFirstChild("Humanoid") then touching = true while touching do print("Touching....") wait() end end end)
script.Parent.TouchEnded:connect(function(untouch) if untouch.Parent:findFirstChild("Humanoid") then touching = false end end)
Make Sure this is in LocalScript for it to work.
local Player = game.Players.LocalPlayer -- Get the local player local char = game.Workspace:WaitForChild(Player.Name) -- Wait for players' character to be added local LeaderStats = Instance.new("IntValue", Player) -- Create Interger Value and parent it to the Player local Level = Instance.new("IntValue", LeaderStats) -- Create Interger Value and parent it to the leaderstats
Hope this help!