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

Player Argument Must Be A Player Option? [SOLVED]

Asked by 5 years ago
Edited 5 years ago

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

0
lmao where's the end)? TrustedInstaIler 17 — 5y
0
There's no need for the end), there isn't a problem with that. killerninja81 30 — 5y
0
Cause that's not the full script. killerninja81 30 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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

Ad

Answer this question