so im wanting to add a simple "finish" system in my game and im very noob at Lua, just started using it a few days ago :P
so i figured an easy way to do a fishing system would be have a brick in the water, they click it and it does an animation which im not worried about atm and every little bit it adds gold to their gold.
i thought this would be easy for me to add but i guess not, this is what i came up with, and like i said i JUST started Lua so dont be mean if this is a stupid attempt at writing this out
Leaderstats = game.Players.Player:FindFirstChild("Leaderstats") local Enabled = false function onClicked() if Enabled == false then Enabled = true end if Enabled == true then Leaderstats.Gold.Value = Leaderstats.Gold.Value + 10 end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
i guess my question is, how do i change this to actually add gold to my leaderstats when i click the brick, i can figure out how to have to repeat giving gold every little bit. THANKS in advance :)
script.Parent.ClickDetector.MouseClick:connect(function(player) -- Mouse click returns the player who clicked :) local Leaderstats = player:findFirstChild("leaderstats") -- declaring leaderstats if Leaderstats:findFirstChild("Gold") then -- Just double checking the value is there so that scripts don't break :) Leaderstats.Gold.Value = Leaderstats.Gold.Value + 10 -- adds 10 to the value (make sure it's intvalue or numbervalue) end end)