The humanoid Died event isnt working it doesnt work when the health of the humanoid is set to 0:
local Cashier = script.Parent
local MoneyTemplate = script.MoneyTemplate
local open = script.Parent.Open
local closed = script.Parent.Closed
local crashSound = script.Parent.HumanoidRootPart.Crash
local MoneyDropsFolder = game.Workspace.Ignored.MoneyDrops
Cashier.Humanoid.Health = 0
script.Parent.Humanoid.Died:Connect(function()
print("yaya")
crashSound:Play()
for i = 1, 4, 1 do
local Money = MoneyTemplate:Clone()
Money.Name = "Money"
local chosenMoneyValue = math.floor(math.random(250, 500))
Money.Amount.Value = chosenMoneyValue
Money.BillboardGui.MoneyCount.Text = "$"..tostring(chosenMoneyValue)
Money.CFrame = Cashier.HumanoidRootPart.CFrame:ToWorldSpace(CFrame.new(0, -1, 4))
Money.Parent = MoneyDropsFolder
end
task.wait(180)
Cashier.Humanoid.Health = Cashier.Humanoid.MaxHealth
closed.CanCollide = true
closed.Transparency = 0
open.CanCollide = false
open.Transparency = 0
end)
5 Likes
Ripxff
(bhdb)
July 30, 2023, 10:23pm
#2
please make script.Parent a variable youre making your life so much more complicated
is everything else working? is this a localscript or a script?
1 Like
BaconKral
(Zephyria)
July 30, 2023, 10:25pm
#3
Is it a server or client script, and where is it located?
1 Like
Ripxff
(bhdb)
July 30, 2023, 10:26pm
#4
zawg replyin to me like i made the post it should be located in the character as from the instantiation of script.Parent.Humanoid
3 Likes
BaconKral
(Zephyria)
July 30, 2023, 10:27pm
#5
My bad, I clicked some random reply button which I was not supposed to click (aka the wrong reply button).
2 Likes
Add task.wait()
to the top of the script. It gives the task scheduler some time to instantiate everything.
1 Like
You are setting the humanoids health to 0 before you even connect the .Died event. Set the health to 0 afterwards.
local Cashier = script.Parent
local MoneyTemplate = script.MoneyTemplate
local open = script.Parent.Open
local closed = script.Parent.Closed
local crashSound = script.Parent.HumanoidRootPart.Crash
local MoneyDropsFolder = game.Workspace.Ignored.MoneyDrops
script.Parent.Humanoid.Died:Connect(function()
print("yaya")
crashSound:Play()
for i = 1, 4, 1 do
local Money = MoneyTemplate:Clone()
Money.Name = "Money"
local chosenMoneyValue = math.floor(math.random(250, 500))
Money.Amount.Value = chosenMoneyValue
Money.BillboardGui.MoneyCount.Text = "$"..tostring(chosenMoneyValue)
Money.CFrame = Cashier.HumanoidRootPart.CFrame:ToWorldSpace(CFrame.new(0, -1, 4))
Money.Parent = MoneyDropsFolder
end
task.wait(180)
Cashier.Humanoid.Health = Cashier.Humanoid.MaxHealth
closed.CanCollide = true
closed.Transparency = 0
open.CanCollide = false
open.Transparency = 0
end)
Cashier.Humanoid.Health = 0
4 Likes
dragnmer
(Xerto)
July 30, 2023, 11:27pm
#9
Not sure what youre actually trying to do here but I wouldn’t use the Died event for such a scenario because configuring the Health value isnt in any local function but made as a global change in the script or localscript. You can remove the Died event for the script to work. Everything else seems good to me.
–>||Kindly use more Identifiers||
1 Like
its a script and yes i will rn imn focusing on functionality
thje health gets put to 0 but it doesnt fire
try setting it to 1, wait like 0.2 seconds, and then set it to 0. Tell me when happens then.
1 Like
Try humanoid:break joints something like that
1 Like
It seems like it just needed a little more time thanks for helping
system
(system)
Closed
August 14, 2023, 3:43pm
#15
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.