Assuming you want the script to be triggered when the player dies, there’s an easier way using Humanoid.Died:Connect()
something like this
local playerCharacter = script.Parent
local function onDied()
local function onTouch(otherPart)
local otherCharacter = otherPart.Parent
-- here you had written otherPart:FindFirstChildOfClass("Humanoid") which will always return false
if otherCharacter then
if otherCharacter:FindFirstChildOfClass("Humanoid") and otherCharacter ~= playerCharacter then
local slowness = game:GetService("ServerStorage").fx.Slowness:Clone()
slowness.Parent = otherCharacter
-- if you don't clone it then you'd lose the original later on
local explosion = Instance.new("Explosion")
explosion.BlastPressure = 0
explosion.Parent = workspace
explosion.Position = script.Parent.HumanoidRootPart.Position
local light = Instance.new("PointLight")
light.Parent = script.Parent.Torso
light.Brightness = 300
light.Range = 5
task.wait(1)
light:Destroy()
-- the rest of the sequence should be inside the function
end
end
end
playerCharacter.HITSPHERE.Touched:Once(onTouch)
end
playerCharacter.Humanoid.Died:Connect(onDied)
This doesnt quite work. I inputted a print(otherCharacter) into it to check if it was connecting to it after a few times it failed, and it isnt printing.
Is the script meant to only work after the player dies?
From what was written, I gathered it was meant to explode someone else if they touched the HITSPHERE after you die.
If that’s not the case, I’d be more than happy to change it to work how you’d ask, I just need to know specifically how you want it to work