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)
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.
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)
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
Using print statemnet like that are very good for finding if / koop issues…
The next level for debugging is to use print statement with info where the code is at, and also when usefull adding variables to the print statements to know what they are set to
This simple debugging step, simple as it is can help trouble shoot issue