First off, the numbers for math.random should be enclosed with Parenthesis, secondly, they should be separated with Commas or Semi-Colons, for Instance, q=math.random(2,6) or q=math.random(2;6)
Another thing, I'd take the onClicked function out of the PlayerAdded event, put it maybe like this:
function onClicked()
end
game.Players.PlayerAdded:connect(function(Player)
end)
thought that's just me.
Fourth, I'd remove the Parenthesis from the strings, I'm not sure whether that'd error or not...
Finally, You'd want to check to make sure everything is where it's supposed to be before running your code...
(Also, the MouseClick event from the ClickDetector returns the Player automatically)
It should look like this in my opinion
function onClicked(Player)
local LS=Player:FindFirstChild("leaderstats")
if not LS then return end
local Stat=LS:FindFirstChild("Maple Leaves")
if not Stat then return end
if script.Parent.Name=="Sell Lemonade" then
wait(.4)
script.Parent.Name="Selling one cup of lemonade..")
wait(q)
script.Parent.Name="Someone has bought a cup of lemonade!"
Stat.Value=Stat.Value+4
wait(.2)
script.Parent.Name="Sell Lemonade"
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
3 comments
No offense, but what ARE you doing correct?
I'm trying, sorry if I made careless errors
@ForeverDev Would you not shoot people down just because you think you're better than them? You were most likely like this when you just started...