Fire effect dosent disaper

Asw the titel already says the effect should disaper when the gui is not visbel any more but it dosent work

example:

here is my code:

local part = script.Parent
local fire = game.ReplicatedStorage.Fire.Fire
local debris = game:GetService("Debris")

local debounce = {}

part.Touched:Connect(function(hit)
	local char = hit.Parent
	local hum = char and char:FindFirstChild("Humanoid")
	if not hum then return end

	local player = game.Players:GetPlayerFromCharacter(char)
	if not player or debounce[player] then return end

	local gui = player:WaitForChild("PlayerGui")
	local fireGui = gui.Effects.Frame.ScrollingFrame:FindFirstChild("Burning")
	if not fireGui then return end

	-- Debounce activation
	debounce[player] = true

	-- Only trigger fire if GUI is hidden
	if not fireGui.Visible then
		fireGui.Visible = true

		-- Apply fire effect to each part of the character
		for _, p in pairs(char:GetChildren()) do
			if p:IsA("Part") then
				local fireClone = fire:Clone()
				fireClone.Parent = p
			end
		end
	end

	-- Only connect once
	local connection
	connection = fireGui:GetPropertyChangedSignal("Visible"):Connect(function()
		if not fireGui.Visible then
			-- Remove the fire from all parts of the character when the GUI is hidden
			for _, p in pairs(char:GetChildren()) do
				if p:IsA("Part") then
					local fireEffect = p:FindFirstChild("Fire")
					if fireEffect then
						fireEffect:Destroy()
					end
				end
			end

			-- Disconnect the event listener and reset debounce
			connection:Disconnect()
			debounce[player] = nil
		end
	end)
end)

Hope you can help me
Thank you :slightly_smiling_face:

1 Like

Add some print debug lines after ever if or loop or check, and see where it is getting to , and not get to

1 Like

so i found out that at the ecxat check 2 it dosent work but after half an hour i cant figure out wahts wrong, maybie its because i worked too much on my game and got a burnout i think i will look tomorow more on this problem but still i hope some one has an idea.
:saluting_face:

local part = script.Parent
local fire = game.ReplicatedStorage.Fire.Fire
local debris = game:GetService("Debris")

local debounce = {}

part.Touched:Connect(function(hit)
	local char = hit.Parent
	local hum = char and char:FindFirstChild("Humanoid")
	if not hum then return end

	local player = game.Players:GetPlayerFromCharacter(char)
	if not player or debounce[player] then return end

	local gui = player:WaitForChild("PlayerGui")
	local fireGui = gui.Effects.Frame.ScrollingFrame:FindFirstChild("Burning")
	if not fireGui then return end

	-- Debounce activation
	debounce[player] = true

	-- Only trigger fire if GUI is hidden
	if not fireGui.Visible then
		fireGui.Visible = true
		print("check1")
		-- Apply fire effect to each part of the character
		for _, p in pairs(char:GetChildren()) do
			if p:IsA("Part") then
				local fireClone = fire:Clone()
				fireClone.Parent = p
			end
		end
	end

	-- Only connect once
	local connection
	connection = fireGui:GetPropertyChangedSignal("Visible"):Connect(function()
		print("check2")
		if not fireGui.Visible then
			-- Remove the fire from all parts of the character when the GUI is hidden
			for _, p in pairs(char:GetChildren()) do
				if p:IsA("Part") then
					local fireEffect = p:FindFirstChild("Fire")
					if fireEffect then
						print("check3")
						fireEffect:Destroy()
					end
				end
			end

			-- Disconnect the event listener and reset debounce
			connection:Disconnect()
			debounce[player] = nil
		end
	end)
end)

This appears to be a server script, are you sure the visibility of the GUI object changes on the server?

1 Like

again, I would add more print statements , after every time a thing is checked or entered…

so like here also…

This will help tell you if , after the part is touched once, is it getting back into the code on another touch, … also is it stuck in a loop…

and like person above said, does it need to be a local script…

I also assume from what you said, it never goes into the print and you see check 2…

if you want to share a working .rbxl file of just this gui and part stuff, (particles ) I am sure we could figure it out by playing with it in studio

since you have banged your head and showed effort , we can help more . up to you…

1 Like

So after some thinking i realised that you were correct it is alway stuck in a loop so i came to the conclusion that putting everthing in one script wont work so i did this:

the script that was in the part that sets the player on fire will give the player the effect

script inside the Part:

local part = script.Parent
local fire = game.ReplicatedStorage.Fire.Fire
local debris = game:GetService("Debris")

local debounce = {}

part.Touched:Connect(function(hit)
	local char = hit.Parent
	local hum = char and char:FindFirstChild("Humanoid")
	if not hum then return end

	local player = game.Players:GetPlayerFromCharacter(char)
	if not player or debounce[player] then return end

	local gui = player:WaitForChild("PlayerGui")
	local fireGui = gui.Effects.Frame.ScrollingFrame:FindFirstChild("Burning")
	if not fireGui then return end

	-- Only trigger fire if GUI is hidden
	if not fireGui.Visible then
		fireGui.Visible = true
		print("check1")
		-- Apply fire effect to each part of the character
		for _, p in pairs(char:GetChildren()) do
			if p:IsA("Part") then
				local fireClone = fire:Clone()
				fireClone.Parent = p
			end
		end
		
	end
end)
-- i need to add still things in so i can reactivated when the player touches again

and inside the fire gui the local script is the part were its getting removed and that the server also removes it i used finally for the first time remoteEvent (I always asked myself waht makes them usefull but now i know it)

Local script:

local player = game.Players.LocalPlayer
local removeFire = game.ReplicatedStorage.RemoteEvents.RemoveFire
local char = player.Character
local debrie = game:GetService("Debris")
local PressE = player:WaitForChild("PlayerGui").PressE
local fireOverlay = PressE.Frame

fireOverlay.Visible = true
fireOverlay.BackgroundTransparency = 0.7


if PressE.Enabled == true then
	while task.wait(0.1) do
		fireOverlay.BackgroundTransparency = 0.5 + math.random() * 0.2
	end
end

PressE:GetPropertyChangedSignal("Enabled"):Connect(function()
	if PressE.Enabled == false then
		removeFire:FireServer()
	else
		print("is true")
	end

end)

and last but not least i placed anothere script in severscript storage for the remote event

Sever script:

local remote = game.ReplicatedStorage.RemoteEvents.RemoveFire
local debrie = game:GetService("Debris")

remote.OnServerEvent:Connect(function(player)
	local char = player.Character
	if not char then return end
	
	for _,part in pairs(char:GetChildren()) do
		if part:IsA("Part") then
			for _,Attach in pairs(part:GetChildren()) do
				if Attach:IsA("Attachment") then
					if Attach.Name == "Fire" then
						debrie:AddItem(Attach,0)
					end
				end
			end
		end
	end
end)

and with all that it works fine:
Client

server view:

thank you two really much for helping me figure it out waht the problem is :saluting_face: