I want to make a script where if a player gets detained, they get teleported to a certain X,Y using HumanoidRootPart when the person detaining the player presses a “Jail” TextButton. I have a slight idea of how to do it but not sure how to do it to only a specific person that’s in cuffs.
I would have to make a script in the jail text button which would teleport the player cuffed to a certain X,Y. Example: game.Players.PlayerCuffed.Character.HumanoidRootPart.CFrame = CFrame.new(0, 0, 0)
The thing I don’t know how to do, is for it only to affect the player that is detained not all the players. Basically I just need to create a variable that defines the cuffed player. Example: local PlayerCuffed = ………. So then I can make it only affect the cuffed player. I know this is kinda hard to understand but yeah I just need something to define the cuffed player apart from the rest of the players. Thank you for your time!
Hey DrTryarus685, I hope your day is going well. It was kind of hard to understand what you're truly trying to achieve. Here are a few functions that might aid you with comments.
function Cuff(player) -- I personnaly would create a cuff function to check wether the player is cuff or not. local Cuff = Instance.new('StringValue') -- Create a simple StringValue. Cuff.Name = 'Cuff' -- Name the StringValue "Cuff" or anything you want. Cuff.Parent = player -- Parent the StringValue to the player. This would label the player as a cuffed player. end function UnCuff(player) -- I added this function just incase you would want to uncuff the player. if player:FindFirstChild("Cuff") then -- I check if the player has cuffs on. player:FindFirstChild("Cuff"):Destroy() -- if the conditional statement is true, I remove them. end end function MoveCuffedPlayer(player,location) -- This function is to move/teleport the cuffed player. The parameters contain the player and the location. The location must be a vector3 Value. if player:FindFirstChild("Cuff") then -- I first check if the player has cuffs on. If so... local Character = player.Character -- From here I define the character. local HumanoidRootPart = Character.HumanoidRootPart -- Next, I get the humanoidRootPart. HumanoidRootPart.CFrame = CFrame.new(location) -- I change the CFrame of the CUFFED player humanoidRootPart. end end --Here's an example-- task.wait(1) Cuff(game.Players['zacdave']) task.wait(5) MoveCuffedPlayer(game.Players['zacdave'],Vector3.new(5,5,5)) task.wait(3) UnCuff(game.Players['zacdave'])
Hopefully this helps!