Upon clicking a brick, a set amount of leaderboard points will be subtracted and the player will have an item. This is what I've got so far. What am I doing wrong? This is for a supermarket/shop in my city.
function click(x) local y = x.Backpack local z = game.ReplicatedStorage["Kelpo"] if x.leaderstats.Points.Value >= 20 then z:Clone().Parent = y x.leaderstats.Points.Value = x.leaderstats.Points.Value - 20 end end
script.Parent.ClickDetector.MouseClick:connect(click)
What may be the problem is that "Kelpo" isn't there yet. Here's something that might fix your code:
local function click(x) -- the wiki has local in front function in ClickDetectors so I'm gonna put one here local y = x.Backpack local z = game.ReplicatedStorage:WatForChild("Kelpo") if x.leaderstats.Points.Value >= 20 then z:Clone().Parent = y x.leaderstats.Points.Value = x.leaderstats.Points.Value - 20 end end script.Parent.ClickDetector.MouseClick:connect(click)