Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?

2 comments

0

D E B U G

0

debug shows that the requirements aren't met somehow

1 answer

✓ Accepted answer

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)

1 comment

0

This Works, Thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.