GUI not showing up once the player touches a part

I’ve been editing this script so when a player touches a certain part, an ImageLabel will fade onto screen, then fade away. It’ll also delete the part once the ImageLabel has faded. But for some reason, it deletes the part without displaying the ImageLabel. There’s no errors in the console.

LocalScript I used:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local showGUIEvent = ReplicatedStorage:WaitForChild("ShowGUIEvent")

local function showAndFadeGUI()
	local player = game.Players.LocalPlayer
	local playerGui = player:WaitForChild("PlayerGui")
	local gui = playerGui:FindFirstChild("QuestUI")

	if gui then
		gui.Enabled = true
		wait(5)

		for transparency = 1, 0, -0.1 do
			gui.IgnoreGuiInset = true
			gui.BackgroundTransparency = transparency
			wait(0.1)
		end

		gui.Enabled = false
	end
end

showGUIEvent.OnClientEvent:Connect(function()
	showAndFadeGUI()
end)

local partName = "QuestUpdated"
local targetPart = game.Workspace:WaitForChild(partName)

targetPart.Touched:Connect(function(hit)
	local character = game.Players:GetPlayerFromCharacter(hit.Parent)
	if character and character:IsA("Player") then
		targetPart:Destroy()
		showGUIEvent:FireServer(character)
	end
end)

Script I used:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local showGUIEvent = Instance.new("RemoteEvent")
showGUIEvent.Name = "ShowGUIEvent"
showGUIEvent.Parent = ReplicatedStorage

showGUIEvent.OnServerEvent:Connect(function(player)
	showGUIEvent:FireClient(player) -- Fire the RemoteEvent to show the GUI for the player
end)

1 Like

I think you can just do “showAndFadeGUI()” when touched, there’s no need for a remote event in this case. Also, i recommend using TweenService for fading the gui.