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

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

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)

2 comments

0

Did you try taking out line 28?

0

Try printing placing print(humanoid.Parent.Name) to see who it is damaging, then you can find out why

3 answers

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.

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)

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)

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