GUI does not show after remote event fires to client

I want to have a part where when a player touches it, a half transparent GUI appears on their screen like they took damage. I used remote events for this but the GUI did not appear. I tried to do this in the past before but the same issue happened.

This is the server script:

local debounce = false
local part = script.Parent
local explosion = part:WaitForChild("ParticleEmitter")
local SFX = part:WaitForChild("Punch Kit Beefy Hit 5 (SFX)")
local dmgEvent = game.ReplicatedStorage.DamageGUI

local function onTouch(hit)
	local hum = hit.Parent:FindFirstChild("Humanoid")
	if hum and not debounce then
		debounce = true
		local player = players:GetPlayerFromCharacter(hit.Parent)
		local dmgGUI = game.StarterGui.HarmGUI.HarmFrame
		print("Debounce is working??")
		dmgEvent:FireClient(player, dmgGUI)
		local A = part:Clone()
		A.Parent = game.Workspace
		A.Position = part.Position +, 0, 0)
		debounce = false


This is the local script:

local dmgEvent = game.ReplicatedStorage.DamageGUI

local function onClient(dmgGUI)
	print("Frame visible g shi")
	dmgGUI.Visible = true
	dmgGUI.Visible = false


Whenever I test it out, this happens: Video

The output prints that the frame appears but it does not. All help is appreciated, thank you.

Im not strong in scripting but it does look like maybe you are making a gui visible that is in StarterGui when it should be in PlayerGui.

You’re doing it in StarterGui. When the game loads, the game takes the GUIs in StarterGui and use it as a template to copy it in a player’s PlayerGui. If you want to modify a GUI in-game, use PlayerGui instead.

I’m pretty sure you should just try setting your gui to a variable in the local script. If the event is firing everything should still work.

This worked, thank you. Is there any way to define a playerGUI in a server script instead of a local script?

I am pretty sure you can use RemoteEvents. Fire the client and then define the PlayerGui in the serverside script. Something like:

local ReplicateStorage = game:GetService("ReplicatedStorage").["Your remote event here."]


--/[Server-side Script]\--
local Rep = game:GetService("ReplicatedStorage").["Your remote event here."]

     local yourgui = player.PlayerGui.["Your GUI here."]
     print("GUI is now enabled!")
     yourgui.Enabled = true
     print("GUI is no longer enabled...")
     yourgui.Enabled = false

Edit: Put the localscript in wherever you want. StarterGui, StarterPlayerScripts, whatever, as long as it’s not in ServerScriptService or any places that only server-side scripts run! :sweat_smile:

1 Like