I want the player to stand beside the person after they interact with the proximity prompt. This works the first time but after spamming arrest and release the player will gradually start moving up. There are no errors or warnings.
Server script that creates the weld and moves the player:
script.Parent.Triggered:Connect(function(player)
wait(0.5)
if player.Shift.Value == true then
player.Character.Humanoid.JumpPower = 0
script.Parent.Enabled = false
player.PlayerGui.Arrest.Enabled = true
local theprompt = script.Parent
script.Parent.Parent.Parent.Humanoid.Health = math.huge
game.ReplicatedStorage.ArrestHide:FireClient(player, theprompt)
script.Parent.Arrester.Value = player
game.ReplicatedStorage.Arrest:FireClient(game.Players:FindFirstChild(script.Parent.Parent.Parent.Name), "no")
local moveposition = Vector3.new(player.Character.Handcuffs.Moved.Position.X, player.Character.Handcuffs.Moved.Position.Y + 1, player.Character.Handcuffs.Moved.Position.Z)
script.Parent.Parent.Parent:MoveTo(player.Character.Handcuffs.Moved.Position)
script.Parent.Parent.Parent.LowerTorso.Orientation = player.Character.Handcuffs.Moved.Orientation
if not script.Parent.Parent.Parent.LowerTorso:FindFirstChild("ArrestWeld") then
local weld = Instance.new("WeldConstraint")
weld.Name = "ArrestWeld"
weld.Part0 = script.Parent.Parent.Parent.LowerTorso
weld.Part1 = player.Character.Handcuffs.Moved
weld.Parent = script.Parent.Parent.Parent.LowerTorso
end
script.Parent.Parent.Parent.Humanoid.WalkSpeed = 0
script.Parent.Parent.Parent.Humanoid.JumpPower = 0
end
end
end
end)
Script that deletes the weld:
game.ReplicatedStorage.ArrestOptions.OnServerEvent:Connect(function(player,option)
if option == "detain" then
for _,child in pairs(workspace:GetDescendants()) do
if child.Name == "Arrester" then
if child.Value == player then
child.Value = nil
child.Parent.Enabled = true
player.PlayerGui.Arrest.Enabled = false
child.Parent.Parent.Parent.Humanoid.WalkSpeed = 16
child.Parent.Parent.Parent.Humanoid.JumpPower = 50
child.Parent.Arrester.Value = nil
child.Parent.Parent.Parent.LowerTorso.ArrestWeld:Destroy()
player.Character.Humanoid.JumpPower = 50
wait(1)
child.Parent.Enabled = true
end
end
end
elseif option == "release" then
for _,child in pairs(workspace:GetDescendants()) do
if child.Name == "Arrester" then
if child.Value == player then
child.Value = nil
player.PlayerGui.Arrest.Enabled = false
child.Parent.Parent.Parent.Humanoid.WalkSpeed = 16
child.Parent.Parent.Parent.Humanoid.JumpPower = 50
child.Parent.Enabled = true
child.Parent.Parent.Parent.LowerTorso.ArrestWeld:Destroy()
child.Parent.Arrester.Value = nil
local hide = "hide"
game.ReplicatedStorage.Arrest:FireClient(game.Players:FindFirstChild(child.Parent.Parent.Parent.Name),hide)
player.Character.Humanoid.JumpPower = 50
wait(1)
child.Parent.Enabled = true
end
end
end
elseif option == "frisk" then
for _,child in pairs(game.Players:GetChildren()) do
local inv = child.Backpack:GetChildren()
if child.Character.ArrestProximity.Arrester.Value == game.Players.LocalPlayer then
script.Parent.Frisk.Items.Text = "Found " .. repr(inv)
end
end
end
end)