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

What am I doing wrong?

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)

1 answer

✓ Accepted answer

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)

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