RemoteEvent Not working

Currently I am trying to use a proximity prompt to let the player interact and change the ‘Money’ leaderstat, but I have tried multiple different ways like using a local script to check if the player has triggered the proximity prompt, I’ve used normal scripts that trigger a local script to cause the trigger, but nothing seems to work, can you help.

Code

Script that handles the Proximity Prompt Trigger

script.Parent.Triggered:Connect(function(player)
	game.ReplicatedStorage.GiveMoney:FireClient(player, 10)
end)

Code that is triggered by the script above

game.ReplicatedStorage.GiveMoney.OnClientEvent:Connect(function(player, GiveAmount)
	game.ReplicatedStorage.GiveMoney:FireServer(GiveAmount)
end)

The script that deals with the remote event triggers

game.ReplicatedStorage.GiveMoney.OnServerEvent:Connect(function(player, AmountGiven)
	player.leaderstats.Money.Value += AmountGiven
	print("Given",AmountGiven,'To',player)
end)

the remote event script works, i checked with a GUI button

What does your code look like?

Ive edited the post to add the code for all the scripts

Your remotes can be spoofed by exploiters. Also, OnClientEvent doesn’t pass the player because you’re already on the client so you can get the player separately. Only have the GiveAmount parameter.

How can they be spoofed? i thought they were quite secure

On your client portion, you do this:

game.ReplicatedStorage.GiveMoney.OnClientEvent:Connect(function(GiveAmount)
	game.ReplicatedStorage.GiveMoney:FireServer(GiveAmount)
end)

An exploiter, can just do this:

game.ReplicatedStorage.GiveMoney.OnClientEvent:Connect(function(GiveAmount)
	game.ReplicatedStorage.GiveMoney:FireServer(999999)
end)

Just set the player’s money from the initial server script.

You don’t need to fire a remote to the client to fire a remote back to the server. If you need to fire from a server script to another server script you can use BindableEvent | Roblox Creator Documentation which would look something like this :

-- trigger script
script.Parent.Triggered:Connect(function(player)
	game.ReplicatedStorage.GiveMoney:Fire(player, 10)
end)
-- give money script
game.ReplicatedStorage.GiveMoney.Event:Connect(function(player, AmountGiven)
	player.leaderstats.Money.Value += AmountGiven
	print("Given",AmountGiven,'To',player)
end)
1 Like

I don’t recommend giving money by using a button. Exploiters can make a loop that runs the event and can get a ton of money.

Unless u have a way to check if the player is actually not exploiting or has the perms to do that in the serverscript that gives the coins then it’s fine.

As people in the replies have pointed how the way you do this is very unsecure especially when .Triggered is fired on the server as well.
So what you’ll probably want to do is remove those last 2 parts and update their money inside of the ProximityPrompt.Triggered event.
Ex

ProximityPrompt.Triggered:Connect(function(player)
    player.leaderstats.Money.Value += 10
    print("Money added to player: "..player.Name)
end)
-- Make sure this is a server script

The number 1 rule when dealing with remote events/functions is to never trust the client
Never give the client a remote event that with its passed arguments can edit things like their money on the server
As @0xzemqkaixlqpolwmzvn said if you want to communicate from script to script use a BindableEvent