What do you want to achieve? Keep it simple and clear!
I want that when the player dies the freeze tween stops
What is the issue? Include screenshots / videos if possible!
The problem is that it works but only once, that means that if i die once it works but if i die again it doesnt work
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried using a while wait() do loop but it didnt work
Heres the code, its a local script located inside a gui
--
local plrs = game:GetService("Players")
local plr = plrs.LocalPlayer
local gui = script.Parent
local image = gui.ImageLabel
local sound = gui.Freeze_s
local char = plr.Character
local hum = char.Humanoid
local ts = game:GetService("TweenService")
local ti = TweenInfo.new(
0.5,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
local canceltween = ts:Create(image,ti,{ImageTransparency = 1})
local cancelsound = ts:Create(sound,ti,{Volume = 0, Playing = false})
hum.Died:Connect(function()
canceltween:Play()
cancelsound:Play()
end)
I think the issue is that after you die, you get a new humanoid, meaning you have to change the humanoid variable to the new humanoid. Try getting the humanoid after the player’s character respawns like this:
plr.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
hum.Died:Connect(function()
canceltween:Play()
cancelsound:Play()
end)
end)
local function onCharAdded(char)
char:WaitForChild("Humanoid").Died:Connect(function()
-- play tweens
end)
end
plr.CharacterAdded:Connect(onCharAdded)
if plr.Character then
onCharAdded(plr.Character)
end