Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can someone help me with this leader board stat script with a strange error?

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)

2 comments

0

Is this a local script?

0

Please format the script in your question.

1 answer

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!

2 comments

0

Thanks!

0

May you please accept it as an answer

This discussion is preserved as it was. New answers, comments, and votes are closed.