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

I get a bunch of errors in my Roblox Item purchasing script. Anyone know how to fix this?

Asked by 2 years ago

I've scripted for about a year but I've never seemed to be able to work with leader stats. I get a bunch of errors in the script when I try to make them purchase an item via click detector. Any fixes in errors?

Script: function onPlayerEntered(newPlayer) wait(.5) local stats = Instance.new("IntValue") stats.Name = "leaderstats"

local score = Instance.new("IntValue")

score.Name = "Money"
score.Value = 0

score.Parent = stats    
stats.Parent = newPlayer

end

game.Players.ChildAdded:connect(onPlayerEntered)

script.Parent.ClickDetector.MouseClick:Connect(function(hit) local function buy(plr) local leaderstats = plr:FindFirstChild('leaderstats') if leaderstats then local cash = leaderstats:FindFirstChild('Money') if cash and cash.Value <= 50 then cash.Value = cash.Value-50 end end end end

0
There's no leaderboard because the stats variable is an IntValue. It should be a folder. MarkedTomato 810 — 2y
0
put the code into a code block properly. Also, check the output for errors and tell us what they are MarkedTomato 810 — 2y
0
"game.Players.ChildAdded:Connect(onPlayerEntered) is really unreliable way to tell if the player joined. replace it with this "game.Players.PlayerAdded:Connect(OnPlayerEntered)" MarkedTomato 810 — 2y
0
Your code isn't running because you put it inside a function that was never called. MarkedTomato 810 — 2y

Answer this question