I have no idea why this doesn’t work as it doesn’t put anything in the output. Heres the prison script that configures all the values:
local Players = game:GetService("Players")
local DSS = game:GetService("DataStoreService")
local PrisonDataStore = DSS:GetDataStore("PrisonData")
local PrisonTimerDataStore = DSS:GetDataStore("PrisonTimer")
local Cells = game.Workspace.Map.Buildings.Governmental.Jail.Cells
Players.PlayerAdded:Connect(function(player)
local prisonFolder = Instance.new("Folder", player)
prisonFolder.Name = "prisonFolder"
local inPrison = Instance.new("BoolValue", player)
inPrison.Name = "inPrison"
inPrison.Parent = prisonFolder
inPrison.Value = PrisonDataStore:GetAsync(player.UserId) or false
local jailTimer = Instance.new("NumberValue", player)
jailTimer.Name = "jailTimer"
jailTimer.Parent = prisonFolder
jailTimer.Value = PrisonTimerDataStore:GetAsync(player.UserId) or 0
inPrison.Changed:Connect(function()
PrisonDataStore:SetAsync(player.UserId, inPrison.Value)
end)
jailTimer.Changed:Connect(function()
wait(5)
PrisonTimerDataStore:SetAsync(player.UserId, jailTimer.Value)
end)
end)
& Heres the actual prison script that is susposed to document your time:
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local JailTimer = player:WaitForChild("prisonFolder"):WaitForChild("jailTimer")
local inPrison = player:WaitForChild("prisonFolder"):WaitForChild("inPrison")
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
player.CharacterAdded:Connect(function()
if JailTimer.Value > 0 then
game.ReplicatedStorage.jailEvents.inJail:Fire(player)
inPrison.Value = true
elseif JailTimer.Value <= 0 and inPrison.Value == true then
game.ReplicatedStorage.jailEvents.outofJail:Fire(player)
inPrison.Value = false
end
end)
end)
game.ReplicatedStorage.jailEvents.inJail.Event:Connect(function(player)
local JailTimer = player:WaitForChild("prisonFolder"):WaitForChild("jailTimer")
local inPrison = player:WaitForChild("prisonFolder"):WaitForChild("inPrison")
while player:WaitForChild("prisonFolder"):WaitForChild("jailTimer").Value > 0 do
print("Time Remaining: "..player:WaitForChild("prisonFolder"):WaitForChild("jailTimer").Value)
wait(1)
player:WaitForChild("prisonFolder"):WaitForChild("jailTimer").Value = player:WaitForChild("prisonFolder"):WaitForChild("jailTimer").Value - 1
end
print("Player is out of prison")
inPrison.Value = false
end)
game.ReplicatedStorage.jailEvents.outofJail.Event:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
local Humanoid = character:WaitForChild("Humanoid")
local RootPart = character:WaitForChild("HumanoidRootPart")
local TargetPosition = Vector3.new("218.881, 151.507, 2512.07")
RootPart.CFrame = CFrame.new(TargetPosition)
end)
but nothing happens & I am so confused why.