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

help with can collide false damage brick spinners not killing?

Asked by
adolof -8
4 years ago
Edited 4 years ago

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)
0
Please format your code. It's simple. Just select your code, press the blue "lua" button, and your done! User#30567 0 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago

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)
0
it works even if the spinner is can collide false? adolof -8 — 4y
0
DUDE IT DOES THANK YOU I HAVE BEEN SEARCHING FOR ANSWERS FOR 2 DAYS IN A ROW YOU ARE A IDOL THANKS adolof -8 — 4y
0
No problem. Glad I could help CreationNation1 459 — 4y
Ad
Log in to vote
0
Answered by
iHavoc101 127
4 years ago

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)

0
let me check it! :) adolof -8 — 4y
0
:TakeDamage(-3) would actually heal the player, because you will take negative damage. EllaTheFloofyFox 106 — 4y
Log in to vote
0
Answered by 4 years ago

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)
0
Hey and remember to accept my answer if it fixes your problem! :) EllaTheFloofyFox 106 — 4y

Answer this question