Tween not playing on humanoid died

  1. What do you want to achieve? Just play tween when humanoid dies that’s all.

  2. What is the issue? Lighting doesn’t get disabled nor does the tween play.

  3. What solutions have you tried so far? Tried debugging with prints and got nothing.

LocalScript in StarterCharacter

local Char = players.LocalPlayer.Character
local Frame = game.Lighting.Foggy

Char:FindFirstChildOfClass("Humanoid").Died:Connect(function()
	Frame.Enabled = false
	TweenService:Create(Frame, TweenInfo.new(2), {Size = 0}):Play()
end)
local Char = players.LocalPlayer.Character
local Frame = game.Lighting.Foggy

Char:FindFirstChildOfClass("Humanoid").Died:Connect(function()
	Frame.Enabled = false -- Did you mean to disable this?
	TweenService:Create(Frame, TweenInfo.new(2), {Size = 0}):Play()
end)

Did you mean to disable the frame? Also, this:

local Char = players.LocalPlayer.Character

Should be changed to this:

local Char = players.LocalPlayer.Character or players.LocalPlayer.CharacterAdded:Wait()

and,

Char:WaitForChild("Humanoid").Died:Connect(function()

with the character it is sometimes better to use :WaitForChild()

Yes, i wanna disable the lighting when the humanoid dies however it doesn’t seem to work.

Can you show your entire script?

local TweenService = game:GetService("TweenService")
local players = game:GetService("Players")
local map = workspace:FindFirstChild("Map")
local partt = map:FindFirstChild("Map Rooms"):FindFirstChild("Boiler Room"):FindFirstChild("FogPart")
local frame = game.Lighting.Foggy

--local tween = TweenService:Create(frame, tweenInfo, Goal)
-- array of players currently touching this part
-- manipulated with table.find and table.remove because it's guaranteed not to grow larger than 100 players
local playersTouching = {}



function getPlayerFromRootPart(part)
	return part.Name == "HumanoidRootPart" and game.Players:GetPlayerFromCharacter(part.Parent)
end


		
function onTouch(part)
	if frame.Enabled == false then
		frame.Enabled = true
	end
	local player = getPlayerFromRootPart(part)
	if player ~= players.LocalPlayer then return end
	if table.find(playersTouching, player) then return end 
	table.insert(playersTouching, player)
	TweenService:Create(frame, TweenInfo.new(1), {Size = 10}):Play()
	
	end
	
function onTouchEnded(part)
	local player = getPlayerFromRootPart(part)
	if player ~= game.Players.LocalPlayer then return end
	local index = table.find(playersTouching, player)
	if not index then return end 
	table.remove(playersTouching, index)
	TweenService:Create(frame, TweenInfo.new(2), {Size = 0}):Play()
end


partt.Touched:Connect(onTouch)
	partt.TouchEnded:Connect(onTouchEnded)



local Char = players.LocalPlayer.Character

Char:FindFirstChildOfClass("Humanoid").Died:Connect(function()
	frame.Enabled = false
	TweenService:Create(frame, TweenInfo.new(2), {Size = 0}):Play()
end)
	



Try adding a print after

Char:FindFirstChildOfClass("Humanoid").Died:Connect(function()

to see if the event fires.

If the event fires, it is most definitely part of the tween failing, not the event.

image
Just did that. However the lighting DOES NOT seems to be disabled.

What Class is frame?

30 chaaaaaaaars

image

What class is frame? You just showed the properties…

Frame is BlurEffect as showed in the picture i posted.

local frame = game.Lighting.Foggy

What kind of results are you expecting from the tween?

To be either size 0 or entirely disabled, but none are working.

Is it a Local Script or a Server Script

a localscript found in startercharacter.

Are you getting any errors?
See what prints out when you run this.

Char:FindFirstChildOfClass("Humanoid").Died:Connect(function()
print(frame)
frame.Enabled = false
TweenService:Create(frame, TweenInfo.new(2), {Size = 0}):Play()
end)

I think you should be waiting for the humanoid. I’m not sure. I’ve done a script like this and i had to make a repeat for the humanoid to load.

image
this is what it printed.

I copy-pasted your whole script and it works without any problems. Do you have any other script that might change the BlurEffects’s Size property? Also, can you screenshot the entire output?

local TweenService = game:GetService("TweenService")
local Frame = game.Lighting.Foggy

game.Players.LocalPlayer.CharacterAdded:Wait():WaitForChild('Humanoid').Died:Connect(function()
	Frame.Enabled = false
	TweenService:Create(Frame, TweenInfo.new(2), {Size = 0}):Play()
end)

See if this works.