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

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

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.

4 comments

0

Only a click detector passes the player object as an arg because it works with FE.

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.

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

0

But If I do that on the client side, will it open it for all players?

1 answer

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)

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