Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to control a remotefunction with gui?

Asked by 4 years ago

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?

0
What do you mean by displays it temporarily? Also this is really broad. Dan_PanMan 227 — 4y
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 jovkon123 17 — 4y
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? Its_Monkey 27 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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!

0
Thanks a bunch, sorry I was late to replying! Its_Monkey 27 — 4y
Ad

Answer this question