How do I prevent character from teleporting to welded object unless told to do so

I want the character to teleport to the thrown object after a certain button is pressed only if it’s welded, but the issue is that I can’t get the character to not teleport after the object is welded to a humanoid
I tried doing an if statement for the welding so that if it’s welded then the character cannot move but it still didn’t work.

This is the script for the tool

local Kunai = game.ServerStorage:FindFirstChild("Kunai")
local Tool = script.Parent
Cooldown = false
CDTime = .5

	if Cooldown then return end
	local char = Player.Character
	local newKunai = Kunai:Clone()
	local position = char.Head.Position +,Mouse.p).lookVector * 1 
	newKunai.CFrame =,Mouse.p) *,0,-3)
	--newKunai.CFrame = char.RightHand.CFrame *,0,-3)
	--newKunai.CFrame = char.RightHand.CFrame * CFrame.Angles(0,math.rad(90),0)
	local bodyVelocity ="BodyVelocity")
	bodyVelocity.MaxForce =,5000,5000)
	bodyVelocity.Velocity = Mouse.lookVector*100
	bodyVelocity.Parent = newKunai
	newKunai.Parent = workspace
		if hit.parent:FindFirstChild("Humanoid")then
			newKunai.CFrame = hit.CFrame
			local weld ="Weld")
			weld.Part0 = hit
			weld.Part1 = newKunai
			weld.Parent = newKunai
		char.UpperTorso.CFrame = newKunai.CFrame
	Cooldown = true
	Cooldown = false

and this is the local script for the tool

local Tool = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local animation = script.Animation
local char = player.Character
local hum = char:WaitForChild("Humanoid")

local animTrack = hum:LoadAnimation(animation)


I’ve been on this problem for a while now so I’m not sure what to do, any suggestions will do.


Could you explain a little bit better please? I don’t understand what you’re trying to do. (Not trying to be rude)

I can’t script at all, so I am sorry if this is unhelpful. I think you just do if then else then
It basically will make it so if the button is not clicked it won’t teleport you because you specify that if the button is not pressed it will keep you where you are. Again sorry if this doesn’t help. I code on other websites so I don’t know if you can do this with lua.

1 Like

So basically I’m trying to make a throwable knife that allows you to teleport after a certain time, but if it’s welded to a person or a dummy then it shouldn’t teleport until I press a certain button. I tried using an if statement for the last part but it still didn’t work

I figured it out, thanks ya’ll