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)