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

How do I show my GUI with client and server events?

Hello,

I've been coding a game and I am at the stage where I want everyone to see a GUI when a specific player dies. Here is my script:

local RS = game:GetService("ReplicatedStorage")
local Win = RS:WaitForChild("Win")
local WinGUIEvent = RS:WaitForChild("WinGUIEvent")

Win.OnServerEvent:Connect(function() 
	print("The Target has died")
	WinGUIEvent:FireClient() -- This is the problem
	end
end)

Whenever a player dies the Win event runs. It should then run the WinGUIEvent event but it errors. In the output it says "FireClient: player argument must be a Player object". I assume I should add something between the brackets but I'm not sure what.

If anyone could help it would be much appreciated.

1 answer

✓ Accepted answer

If you're firing to the client you need to specify which client to send the event to, specifically a player instance

.OnServerEvent has the Player parameter as the first option, prioritising first.

Use that Player parameter

local RS = game:GetService("ReplicatedStorage")
local Win = RS:WaitForChild("Win")
local WinGUIEvent = RS:WaitForChild("WinGUIEvent")

Win.OnServerEvent:Connect(function(Player) 
    print("The Target has died")
    WinGUIEvent:FireClient(Player) -- This is the problem
    end
end)

Hope this helps you!

1 comment

0

Thank you so much! You solved my problem!!! :D

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