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

My attack script doesn't damage humanoid?

Asked by 3 years ago

So, I have made a "Attack." It clones a sphere from ServerStorage and makes it grow, hurting anything which touches it but normal players (I have made a R6 Model and named his humanoid BotHumanoid, and then checked if it had BotHumanoid, then makes it take damage, more info in the not working script.)

For some reason it doesn't work, if you can tell me how to fix it, I would be greatful.

bomb.Touched:Connect(function(hit)
        if hit.Parent.Name == "BotHumanoid" then
            local human = hit.Parent.BotHumanoid
            human.Health = human.Health - 10
        end
    end)
--The full script is in the comments, it's pretty long because I don't wanna use a while loop to resize the attack, I have a way to make it smoother, which requires me to do it without a while loop.
0
local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvent = ReplicatedStorage:WaitForChild("BombEvent") local debounce = true RemoteEvent.OnServerEvent:Connect(function(player) local bomb = game.ServerStorage.Bomb:Clone() bomb.Parent = workspace bomb.Anchored = true bomb.CanCollide = false bomb.Position = player.Character.Head.Position + Vector3.new(0, 10, 0) bomb.Ma InterDwarf 14 — 3y

1 answer

Log in to vote
0
Answered by
Punctist 120
3 years ago

Not sure if this is what you wanted but you could try it.

script.Parent.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("BotHumanoid") then
            hit.Parent.BotHumanoid:TakeDamage(5)
    end
end)
0
Also change the (5) to whatever you'd like. Punctist 120 — 3y
Ad

Answer this question