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

help with can collide false damage brick spinners not killing?

hello everyone this is my first post i need help with it. i have been doing a obby game so i tried to create a spinning killbrick thats is not collidable the problem is that when i make it non collidable it doesnt kill anymore. what should i do? i have been trying to fix this without success. here is the script in case you need it. script:

script.Parent.Touched:connect(function(hit)
	if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent.TakeDamage = -3
	end
end)

1 comment

0

Please format your code. It's simple. Just select your code, press the blue "lua" button, and your done!

3 answers

✓ Accepted answer

The problem with that was TakeDamage() was used incorrectly. Also as a side-note, :connect is deprecated to please remember to use :Connect. Additionally, you should be formatting your code correctly. Here is a working damage script:

local part = script.Parent
part.Touched:Connect(function(hit)
	if game.Players:GetPlayerFromCharacter(hit.Parent) then
		local hum = hit.Parent:FindFirstChild("Humanoid")
		hum.Health = hum.Health -3
	end
end)

3 comments

0

it works even if the spinner is can collide false?

0

DUDE IT DOES THANK YOU I HAVE BEEN SEARCHING FOR ANSWERS FOR 2 DAYS IN A ROW YOU ARE A IDOL THANKS

0

No problem. Glad I could help

I believe this would be the answer:

script.Parent.Touched:connect(function(hit)
    if hit and hit:FindFirstAncestorOfClass('Model') then
        local Model = hit:FindFirstAncestorOfClass('Model')
        Model:WaitForChild('Humanoid'):TakeDamage(-3)
    end
end)

but if you want it unformatted for easier copying:

script.Parent.Touched:connect(function(hit) if hit and hit:FindFirstAncestorOfClass('Model') then local Model = hit:FindFirstAncestorOfClass('Model') Model:WaitForChild('Humanoid'):TakeDamage(-3) end end)

2 comments

0

let me check it! :)

0

:TakeDamage(-3) would actually heal the player, because you will take negative damage.

Here's a damage script, Oh and in the future you can click the blue lua button when writing a post to highlight your code

local Damage = 100
script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild('Humanoid') then
		hit.Parent.Humanoid:TakeDamage(Damage)
	end
end)

1 comment

0

Hey and remember to accept my answer if it fixes your problem! :)

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