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

Why does it display player argument must be a player object? [RemoteEvents]

Asked by 5 years ago

There is a TextButton inside a ScreenGui. The TextButton is the one I am using MouseButton1Click.

--This is a script inside the 'TextButton'
local function mouseClicked(player)
    game:GetService("ReplicatedStorage").ShopBuy:FireClient(player)
end

script.Parent.MouseButton1Click:Connect(mouseClicked)
--This is a LocalScript inside the 'ScreenGui' in StarterGui
local remote = game:GetService("ReplicatedStorage"):WaitForChild("ShopBuy")
remote.OnClientEvent:Connect(function()
    script.Parent.Open.Value = true
end)
--This is a LocalScript inside the 'ScreenGui' in StarterGui. This Script will open the Gui with TweenPosition.

if script.Parent.Open.Value == true then
    script.Parent.PromptPurchase:TweenPosition(UDim2.new(0.5,-225,0.5,-150),"Out","Quint",0.1,"true")
end

Note that 'Open' is a BoolValue in the Gui. It will just notify if the Gui should open.

Okay. There is a problem from now.

--Output :
FireClient: player argument must be a Player object

There was a error so I looked up on the Roblox Wiki but still the red output won't go away.

Can anybody tell me why doesn't this script(or localscript) doesn't work and can give a fix if necessary?

Thanks for your support.

0
Only a click detector passes the player object as an arg because it works with FE. User#5423 17 — 5y
0
All gui things should be managed on the client side. In your case there is no need for any remotes. The player should click a button and the gui should be shown. No server action is needed to show / hide a gui. User#5423 17 — 5y
0
We need to see your server script to determine the issue with the fire client, the gui won't open since the if-then statement to open it is outside of the connected function SerpentineKing 3885 — 5y
0
But If I do that on the client side, will it open it for all players? S_H1234 7 — 5y

1 answer

Log in to vote
0
Answered by
sydre 229 Moderation Voter
5 years ago

Because you said that you have this script in a TextButton, I assume that you are using a Local Script. If so, you can use LocalPlayer to get the player,

game:GetService("ReplicatedStorage").ShopBuy:FireClient(game.Players.LocalPlayer)

Ad

Answer this question