Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago

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)

0
Is this a local script? Shadi432 69 — 7y
0
Please format the script in your question. PyccknnXakep 1225 — 7y

1 answer

Log in to vote
0
Answered by
thesit123 509 Moderation Voter
7 years ago

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!

0
Thanks! 246810_Herobrine -5 — 7y
0
May you please accept it as an answer thesit123 509 — 7y
Ad

Answer this question