So I am trying to create a command that will allow administrators to jail other players. However, I am not too sure where I went wrong. Here is my script:
local prefix = ":"
local group = 8708530 -- current beta tester group
game.Players.PlayerAdded:connect(function(plr)
local newJailedVal = script.HolderVals.JailedCopy:Clone()
newJailedVal.Name = "Jailed"
newJailedVal.Value = false
newJailedVal.Parent = game.Workspace:WaitForChild(plr.Name)
plr.Chatted:connect(function(message)
local msg = message:split(" ")
if msg[1] == prefix.."jail" and plr:GetRankInGroup(group) >= 9 then
local target = msg[2]
if game.Workspace:WaitForChild(target).Jailed.Value == false then
return nil
else
target.Character.HumanoidRootPart.CFrame = workspace.Jail.Teleporter.CFrame*CFrame.new(0,3,0)
end
end
end)
end)
Infinite yeld possibleā¦
That would mean it does not find your target?
It would be a little helpful if I could see the yellow error, but Iām assuming either the āJailedā BoolValue is not being found or the ātargetā but I highly doubt it is the target.
Oh. I recommend that you would add the value inside of the player and not the character, that way you could use it even if the character is dead/respawned/nonexistant.
I always put my values inside the player.
From there, you could fire below to access it.
game:GetService('Players')[target].Jailed.Value
Try doing this and see if you get any error. on a quick note, I forgot to ask if the value is a boolean or a string. I assume it is a boolean but just making sure
OHH WAIT I CONFUSED MYSELF. It only teleports the player when the jailed value is set to trueā¦ which is the direct opposite of what Iām trying to do