I Have A Damage Script Inside Of A Part That Is Set To 0.2 Transparency By Another Script, The Code For The Damage Script:
local cooldown = true script.Parent.Touched:connect(function(part) if game.Players:FindFirstChild(part.Parent.Name) and script.Parent.Transparency == 0.2 and cooldown == true then cooldown = false part.Parent.Humanoid.Health = part.Parent.Humanoid.Health -math.random(180000,255000) wait(1) cooldown = true end end)
for some reason this does not work and i don't understand why. There are no errors in the dev console. However, the same script without a cooldown and transparency check works just fine
Working Script:
script.Parent.Touched:connect(function(part) if game.Players:FindFirstChild(part.Parent.Name) then part.Parent.Humanoid.Health = part.Parent.Humanoid.Health - math.random(180000,255000) end end)
Anyone know why the first script won't work?
I would recommend using a BoolValue
to check if the part has been "activated" by the other script. For some reason it seems that checking transparency doesn't work.
local cooldown = true script.Parent.Touched:connect(function(part) if game.Players:FindFirstChild(part.Parent.Name) and script.Parent.BoolValue.Value and cooldown then cooldown = false part.Parent.Humanoid.Health = part.Parent.Humanoid.Health - math.random(180000,255000) wait(1) cooldown = true end end)
Locked by User#24403
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?