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

Grab ability keeps damaging the player, what the hell (?)

Asked by 2 years ago
Edited 2 years ago

As the title says, I made this tool where when you click, you will grab, If you manage to grab a NPC or player, you will yeet them, the problem Is that the ability also damages the player, and the victim as well, like what the actual [Bleep].

Note: The tool has no handle

Script:

local tool = script.Parent
local debounce = false

tool.Activated:Connect(function()
    if not debounce then
        debounce = true
        local SLAP = tool.Parent.Humanoid:FindFirstChild("Animator"):LoadAnimation(tool.Grab)
        SLAP:Play()
        tool.Parent["Right Arm"].Touched:Connect(function(hit)
            local humanoid = hit.Parent:WaitForChild("Humanoid")
            if humanoid ~= tool.Parent.Humanoid then
                humanoid.Parent.Head.Position = humanoid.Parent.Head.Position + Vector3.new(0,-3,0)
                local Weld = Instance.new("Weld",tool.Parent["Right Arm"])
                game:GetService("Debris"):AddItem(Weld,0.46)
                Weld.Part0 = tool.Parent["Right Arm"]
                Weld.Part1 = humanoid.Parent.Head
                local Yeet = tool.Parent.Humanoid:FindFirstChild("Animator"):LoadAnimation(tool.Yeet)
                Yeet:Play()
                wait(0.46)
                local Yeet = Instance.new("VectorForce",humanoid.Parent.Torso)
                local Attachment = Instance.new("Attachment",humanoid.Parent.Torso)
                Yeet.Force = Vector3.new(0,300,-6000)
                Yeet.Attachment0 = Attachment
                Yeet.ApplyAtCenterOfMass = true
                game:GetService("Debris"):AddItem(Yeet,0.5)
                game:GetService("Debris"):AddItem(Attachment,0.5)
                wait(.05)
                humanoid:TakeDamage(250)
            end
        end)
        wait(5)
        debounce = false
    end
end)
0
Did you try taking out line 28? taxicar24 19 — 2y
0
Try printing placing print(humanoid.Parent.Name) to see who it is damaging, then you can find out why Kingu_Criminal 205 — 2y

3 answers

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

The problem is that it damages both of them? and not only the grabbed player? DIdn't quite understand

Assuming problem is damaging BOTH of them... uh...

After reading the whole script like 8 times, I can't really see why would it damage both players.

I don't see a line destroying the weld between the victims head and the player's arm Could it be that the victim is welded to the player so it damages both of them?

If that's not it I recommend you do what's said above, using print() to find out what's it damaging.

Ad
Log in to vote
0
Answered by
Xyternal 247 Moderation Voter
2 years ago

Maybe you can try this? Like you literally have a line that says humanoid:TakeDamage(250)
and then you ask why it is doing damage?

local tool = script.Parent
local debounce = false

tool.Activated:Connect(function()
    if not debounce then
        debounce = true
        local SLAP = tool.Parent.Humanoid:FindFirstChild("Animator"):LoadAnimation(tool.Grab)
        SLAP:Play()
        tool.Parent["Right Arm"].Touched:Connect(function(hit)
            local humanoid = hit.Parent:WaitForChild("Humanoid")
            if humanoid ~= tool.Parent.Humanoid then
                humanoid.Parent.Head.Position = humanoid.Parent.Head.Position + Vector3.new(0,-3,0)
                local Weld = Instance.new("Weld",tool.Parent["Right Arm"])
                game:GetService("Debris"):AddItem(Weld,0.46)
                Weld.Part0 = tool.Parent["Right Arm"]
                Weld.Part1 = humanoid.Parent.Head
                local Yeet = tool.Parent.Humanoid:FindFirstChild("Animator"):LoadAnimation(tool.Yeet)
                Yeet:Play()
                wait(0.46)
                local Yeet = Instance.new("VectorForce",humanoid.Parent.Torso)
                local Attachment = Instance.new("Attachment",humanoid.Parent.Torso)
                Yeet.Force = Vector3.new(0,300,-6000)
                Yeet.Attachment0 = Attachment
                Yeet.ApplyAtCenterOfMass = true
                game:GetService("Debris"):AddItem(Yeet,0.5)
                game:GetService("Debris"):AddItem(Attachment,0.5)
                wait(.05)

            end
        end)
        wait(5)
        debounce = false
    end
end)
Log in to vote
0
Answered by
Xyternal 247 Moderation Voter
2 years ago

Maybe you can try this? Like you literally have a line that says humanoid:TakeDamage(250)
and then you ask why it is doing damage?

local tool = script.Parent
local debounce = false

tool.Activated:Connect(function()
    if not debounce then
        debounce = true
        local SLAP = tool.Parent.Humanoid:FindFirstChild("Animator"):LoadAnimation(tool.Grab)
        SLAP:Play()
        tool.Parent["Right Arm"].Touched:Connect(function(hit)
            local humanoid = hit.Parent:WaitForChild("Humanoid")
            if humanoid ~= tool.Parent.Humanoid then
                humanoid.Parent.Head.Position = humanoid.Parent.Head.Position + Vector3.new(0,-3,0)
                local Weld = Instance.new("Weld",tool.Parent["Right Arm"])
                game:GetService("Debris"):AddItem(Weld,0.46)
                Weld.Part0 = tool.Parent["Right Arm"]
                Weld.Part1 = humanoid.Parent.Head
                local Yeet = tool.Parent.Humanoid:FindFirstChild("Animator"):LoadAnimation(tool.Yeet)
                Yeet:Play()
                wait(0.46)
                local Yeet = Instance.new("VectorForce",humanoid.Parent.Torso)
                local Attachment = Instance.new("Attachment",humanoid.Parent.Torso)
                Yeet.Force = Vector3.new(0,300,-6000)
                Yeet.Attachment0 = Attachment
                Yeet.ApplyAtCenterOfMass = true
                game:GetService("Debris"):AddItem(Yeet,0.5)
                game:GetService("Debris"):AddItem(Attachment,0.5)
                wait(.05)

            end
        end)
        wait(5)
        debounce = false
    end
end)

Answer this question