Hello, I really need help with my handcuffs and the scripts in it.
Almost everything works with my handcuffs, the only thing not working is the part where the serverscript teleports the player to their prison cell. I have looked everywhere for an answer, but no luck.
Here is a part of my serverscript:
RemoteEvent.OnServerEvent:Connect(function(player, state, part) -- state == 'Jail' and part == workspace.Player1
if state == 'Jail' then
Using = false
targetbody.Anchored = false
workspace:FindFirstChild(part.Name).Humanoid.PlatformStand = false
local GetPlayer = game.Players:FindFirstChild(part.Name)
local jailPosition = prisons[math.random(1,#prisons)].Position -- This is the position
GetPlayer.TeamColor = BrickColor.new("Smoky grey")
GetPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(jailPosition) -- This is the problem, it works with the commandbar but not in the script
end
end)
There are no errors, but it won't move the player at all. I have tried using "SetPrimaryPartCFrame"
a part of my Localscript:
local PlayerCuffed -- Equal to workspace.Player1
local Jailing = false
local Using = false
Tool.Unequipped:Connect(function()
Player.PlayerGui.CuffGui.Enabled = false
if PlayerCuffed == nil then return end
Using = false
if not Jailing then
RemoteEvent:FireServer('UnCuff', PlayerCuffed)
PlayerCuffed = nil
end
end)
CuffGui.Jail.JailRound.JailButton.MouseButton1Down:Connect(function()
Jailing = true
local humanoid = Player.Character:FindFirstChildOfClass('Humanoid')
if humanoid then
humanoid:UnequipTools()
end
RemoteEvent:FireServer('Jail', PlayerCuffed)
PlayerCuffed = nil
Using = false
Jailing = false
end)
Hopefully I can find an answer to this question.
EDIT: I did find an answer look at my answer that I posted to this topic.

1 comment
The CFrame was defined correctly, but thanks for trying.