Ok this script is supposed to load a Boolean from the player every time they die, when I change the boolean in game and then use a SaveBoolean on it it works when I respawn except that it doesn't teleport me like it is supposed to however when I rejoin the game the boolean is not how I saved it before I left. It always seems to get set to true when I saved it as false. The script is located inside a BoolValue that is inside the player's backpack.
Plr = script.Parent.Parent.Parent
b = script.Parent
Plr:WaitForDataReady()
if Plr:LoadBoolean("Jailed") and Plr:LoadString("JailReason") ~= nil then
b.Value = Plr:LoadBoolean("Jailed")
elseif Plr:LoadBoolean("Jailed") == nil or Plr:LoadString("JailReason") == nil then
Plr:SaveBoolean("Jailed", false)
b.Value = false
Plr:SaveString("JailReason", "")
end
if b.Value == true then
Plr.Character:MoveTo(Workspace.Jailspawn.Position)
Plr.Character.Humanoid.WalkSpeed = 5
x = Plr.Backpack:GetChildren()
for i = 1, #x do
if x[i]:IsA("Tool") or x[i]:IsA("HopperBin") then
x[i]:remove()
end
end
z = Plr.Character:GetChildren()
for i = 1, #z do
if z[i]:IsA("Tool") then
z[i]:remove()
end
end
j = game.Lighting.JailedB:clone()
j.Parent = Plr.Character.Head
j.TextBox.Text = Plr:LoadString("JailReason")
end
function refresh ()
Plr:SaveBoolean("Jailed", b.Value)
end
b.Changed:connect(refresh)
