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

What am I doing wrong?

Asked by 8 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.

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

Log in to vote
1
Answered by 8 years ago

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)
Ad

Answer this question