Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would i fix this when there are no errors in the dev console? [closed]

Asked by 4 years ago

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?

0
D E B U G Elixcore 1337 — 4y
0
debug shows that the requirements aren't met somehow mm1678YT 80 — 4y

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?

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)
0
This Works, Thanks mm1678YT 80 — 4y
Ad