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

Player Argument Must Be A Player Option? [SOLVED]

Hello everyone, I've been trying to fire a remoteevent, but things aren't going right

Here's what I put down

In a normal script in a GUI button:

local Players = game:GetService("Players")
local player = Players.LocalPlayer

local function mouseclick()
	game.ReplicatedStorage.RewardChange:FireClient(player)
	print("Fired")
end

script.Parent.MouseButton1Down:Connect(mouseclick)

And for the receiving end, there's a localscript in Workspace (I made it local as I'm trying to change the PlayerGui)

game.ReplicatedStorage.RewardChange.OnClientEvent:Connect(function()
	print("received")

I also put my RemoteEvent in Workspace so the localscript

As you can see, I tried troubleshooting it with a print troubleshoot, but that doesn't print.

Thanks, any help would be appreciated

3 comments

0

lmao where's the end)?

0

There's no need for the end), there isn't a problem with that.

0

Cause that's not the full script.

1 answer

✓ Accepted answer

The reason it doesn't work is because you can't fire the client from a client. You can, however, ues a BindableEvent which is basically the same as a RemoteEvent but instead of server to client it's client to client or server to server.

replace "RewardChange" with a BindableEvent

local Players = game:GetService("Players")
local player = Players.LocalPlayer

local function mouseclick()
    game.ReplicatedStorage.RewardChange:Fire(player)
    print("Fired")
end

script.Parent.MouseButton1Down:Connect(mouseclick)


Script 2

game.ReplicatedStorage.RewardChange.Event:Connect(function()
    print("received")

Unless the GUI button is a sever script, in which case LocalPlayer isn't available.

Also, the LocalScript MUST be parented to StarterGui, the Character, StarterPack, or StarterPlayerScripts

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