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

How to control a remotefunction with gui?

I have a remoteevent in replicatedstorage that gives you money everytime you click. I want to make a debug (admin) gui to give the localplayer that is whitelisted money, but when i type the script

script.Parent.MouseButton1Down:Connect(function()
	game.Players.LocalPlayer:WaitForChild("leaderstats").Money.Value = 100000
end)

it doesnt work and only displays it temporarily. how can i fix this?

3 comments

0

What do you mean by displays it temporarily? Also this is really broad.

0

okay since this is in a local script you can't edit the leaderstats for the whole server to see its only you that can see it so by temporarily i assume you mean after you click it resets to its normal value? if that is correct u need to send a signal trough a remote event to a serverscript that will change it for you

0

I see what you mean. Yeah by temporarily I meant that. I apologize for the broad statement. How do I sent that through the remote event to give myself some money?

1 answer

✓ Accepted answer

You can't access the leaderstats from a LocalScript. That's why it'd be good to use your RemoteEvent in ReplicatedStorage. Insert another Script in ServerScriptService. This is what I suggest you have in your scripts:

Local Script

script.Parent.MouseButton1Down:Connect(function()
	game.ReplicatedStorage.RemoteEvent:FireServer()
end)

Server Script

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
	player:WaitForChild("leaderstats").Money.Value = 100000
end)

Hope this helps!

1 comment

0

Thanks a bunch, sorry I was late to replying!

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