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

How do I make the knife not stick to you?

I'm making a throw knife script but when I throw it, Sometimes it sticks to me. I have a weld script so it sticks but I don't know how to make it so it doesn't stick to me and it sticks to other things.

Script:

local Tool = script.Parent

local HitSound = Instance.new("Sound")
HitSound.SoundId = "http://www.roblox.com/asset?id=153647563"
HitSound.Parent = Tool
HitSound.Volume = 0.5

function Stick(hit, player)
	local AV = Tool:findFirstChild("BodyForce")
	local FO = Tool:findFirstChild("BodyAngularVelocity")
	
	if AV ~= nil then AV:Destroy() end
	if FO ~= nil then FO:Destroy() end
	
	if hit.Parent.Name ~= player.Name then
		local weld = Instance.new("Weld")
		weld.Name = "PieWeld"
		weld.Part0 = Tool
		weld.Part1 = hit
		
		local backupweld = Instance.new("Weld")
		backupweld.Name = "PieWeldBackup"
		backupweld.Part0 = Tool
		backupweld.Part1 = hit
		
		local HitPos = Tool.Position
		
		local CJ = CFrame.new(HitPos)
		local C0 = Tool.CFrame:inverse() * CJ
		local C1 = hit.CFrame:inverse() * CJ
		
		weld.C0 = C0
		weld.C1 = C1
		
		weld.Parent = Tool
		
		backupweld.C0 = C0
		backupweld.C1 = C1
		
		backupweld.Parent = Tool
	end
end


function onTouched(hit, player)
	connection:disconnect()
	
	Stick(hit, player)
	HitSound:Play()
end

connection = Tool.Touched:connect(onTouched)

wait(2)

if Tool:FindFirstChild("PieWeld") ~= nil then
	Tool.PieWeld:Destroy()
end

wait(8)

Tool.Parent = nil

[Edit: This is a script, It should stick to others]

I would really appreciate it if you will help me with my problem, Plus I will accept your answer.

Thanks, MajinBluee

4 comments

0

Is this a local script?

0

And should it stick to other players?

0

Did you copy this code? Because Remove is deprecated also :connect ... Use :Destroy and :Connect

0

No its not a local script, Yes it should and yes i copied it and I didn't see the remove thing, You dont need :Connect.

1 answer

✓ Accepted answer

When using your Stick(hit, player) function, check to see if the target hit is the same as the player who is throwing the knife. If they are the same, do not use the function.

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