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

how can i modify this script so it gives the player money?

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

3 comments

0

whats the error you get back from the script?

0

I'll make some tests, but what I can say is that your question or script is wrong with the number.... (want when reach transparency 0 or 1?)

0

What kind of script is it and what location is the script.

1 answer

✓ Accepted answer

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

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