#connections
96 messages · Page 1 of 1 (latest)
local connection
connection = script.Parent.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
if(script.Parent.Humanoid.Health < 2500) then
script.Parent.Head.ParticleEmitter.Enabled = true
halfhp:Play()
script.Parent["Man Screaming"]:Play()
D = 2
end
connection:Disconnect()
end)
doesnt work
tried putting connection:Disconnect() after ```lua
end)
Does the rest of the code in the connection work fine?
the connection doesnt run either
** You are now Level 2! **
after the humanoid is below 2500 hp, it doesnt run
the connection is outside any functions
And this is a script inside the characters model right?
Well I'd assume so that's what you specified in there
That is probably where it's disconnecting
so what should i do
What are you trying to do exactly?
when the health changes to below 50% (2500 hp), it should start the particles, play the audio, and play the animation
not sure what i did wrong there
🤭
And it isn't doing anything at all right now?
the connection doesnt run
I just got here and it's 1 in the morning ok 😭
lemme check again
no, its about him
is it bc im assigning the connection to the connection variable and its not running?
That shouldn't be a problem, I see it done all the time
Let me try writing it out myself rq
kk
Does the formatting work on mobile
its below 2500 hp but still doesnt do the thing
no
Mk
local char = script.Parent; local hum = char:WaitForChild("Humanoid")
local halfhp -- don't know what this is
local con = hum.HealthChanged:Connect(function()
if hum.Health < hum.Health/2 then
print("Under half")
con:Disconnect()
end
end)
OK I kinda skipped out on the content part but I just want to see if this prints before I write the rest out
** You are now Level 1! **
hm wait
local connection
connection = script.Parent.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
if(script.Parent.Humanoid.Health < script.Parent.Humanoid.Health / 2) then
script.Parent.Head.ParticleEmitter.Enabled = true
halfhp:Play()
script.Parent["Man Screaming"]:Play()
D = 2
print("Under half")
end
connection:Disconnect()
end)
like that?
lemme try now
nope doesnt print "Under half"
whats the D = 2
but for what
I want you to test the code I sent specifically to get an idea if I'm on the right track
after half hp the attacks would be faster
hes disconnecting it
my discord was weird so thats the only thing i could make out lemme actually do that again
i deleted the halfhp variable since that doesnt matter after that
i lack the sense called "logic" in the mush called a "brain"
Ah
you do
do yall need my entire script
** You are now Level 3! **
its a bad way to do what i did but here
its 162 lines
this
i cant screenshot all of it
local char = script.Parent; local hum = char:WaitForChild("Humanoid")
local halfhp -- don't know what this is
local con
con = hum.HealthChanged:Connect(function()
if hum.Health < hum.Health/2 then
print("Under half")
con:Disconnect()
end
end)
Aha
cuz hp aint 2500 or less
it was
max hp is 5000 and i hit it until it was clearly below half
nothing got printed
Interesting
My go to strategy is to just add a debug message every line until I find the problem but that's probably not best
is HealthChanged a function?
162 lines 😎
lemme debug each line one by one
🗿
Last I checked it was, of the humanoid st least
Just add a debug between every line of the code I sent for now and find the exact point it breaks, that's probably the most effective way even if it's time consuming
Which is why you only need to debug that part
