Why my script don't work

I have no erro in the output it’s just don’t work

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local uis = game:GetService("UserInputService")
local camera = workspace.CurrentCamera

local teleEnabled = false
local targetedModel = nil
local maxRange = 25

mouse.Button1Down:Connect(function()
	local target = mouse.Target
	if target and target.Parent:FindFirstChild("Humanoid") then
		teleEnabled = true
		targetedModel = target.Parent.PrimaryPart
		local bp = Instance.new("BodyPosition", targetedModel)
		bp.MaxForce = Vector3.new(5e5,5e5,5e5)
		bp.Position = player.Character.HumanoidRootPart.Position
	end
end)

mouse.Button1Up:Connect(function()
	teleEnabled = false
	if targetedModel and targetedModel:FindFirstChild("BodyPosition") then
		targetedModel.BodyPosition:Destroy()
	end
	targetedModel = nil
end)

mouse.Move:Connect(function()
	if teleEnabled == true then
		if targetedModel then
			local location = camera.CFrame.Position + (mouse.Hit.Position - camera.CFrame.Position).Unit * maxRange
			targetedModel.BodyPosition.Position = location
		end
	end
end)

try debugging in some parts of the script

1 Like

Ohhh I think it’s beceause my custom character have accesory beceause when i take the arm it’s work

Ok then it’s work on dummy but not with player