script.Parent.Handle.Touched:Connect(function(hit) if not hit.Parent:FindFirstChild("Humanoid") then return end local player = game.Players:GetPlayerFromCharacter(hit.Parent) if hit.Parent:FindFirstChild("Gun") then hit.Parent:MoveTo(game.Workspace.Prison.Position) return end if player.Backpack:FindFirstChild("Gun") then hit.Parent:MoveTo(game.Workspace.Prison.Position) end)
I want the player to teleport (when touched by the handcuffs) to the prison if they have a gun in their backpack. But when the handcuffs touch the player the player bounces back and forth between the handcuffs and the prison.
You're using MoveTo() which is only for Models and the Humanoid for walking. Just get the HumanoidRootPart and change it's CFrame.
MoveTo() is touchy, would recommend setting the models primary part CFrame using model:SetPrimaryPartCFrame(game.Workspace.Prison.CFrame)
script.Parent.Handle.Touched:Connect(function(hit) if not hit.Parent:FindFirstChild("Humanoid") then return end local player = game.Players:GetPlayerFromCharacter(hit.Parent) if hit.Parent:FindFirstChild("Gun") then hit.Parent.HumanoidRootPart.CFrame=CFrame.new(game.Workspace.Prison.Position) return end if player.Backpack:FindFirstChild("Gun") then hit.Parent:MoveTo(game.Workspace.Prison.Position) end)