i made a script that slowly turns a brick invisible but i want it to give the player money when the transparency reaches 0
here is the script:
script.Parent.MouseClick:Connect(function() script.Parent.Parent.Transparency = script.Parent.Parent.Transparency + 0.25 if script.Parent.Parent.Transparency >= 1 then script.Parent.Parent:Destroy() end end)
here is what i tried but it didnt work:
script.Parent.MouseClick:Connect(function() script.Parent.Parent.Transparency = script.Parent.Parent.Transparency + 0.25 if script.Parent.Parent.Transparency >= 1 then game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value + 5 script.Parent.Parent:Destroy() end end)
thanks
Hello, poopypigeon245!
Analysing your script, I can think this is a Server Script(if not change to) so, Sever Scripts don't know who LocalPlayer
is, you can use the argument of the click detector to solve this, it gives the player...
Edited Script:
script.Parent.MouseClick:Connect(function(plr) --plr is a reference to the player that cliked script.Parent.Parent.Transparency = script.Parent.Parent.Transparency + 0.25 if script.Parent.Parent.Transparency >= 1 then plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 5 --Changed game.Player.LocalPlayer to plr (the reference to the player) script.Parent.Parent:Destroy() end end)
Good Luck with your games