I want to script a script that puts players in prison for an amount of time & lets them out after. I have found not a single tutorial on this, and my scripts do not work and I have no idea why. I’m at a blank slate because if I finished the prison script then my game would be complete and it’s really hindering my progress. I don’t need “Find out for yourself” or “Look it up online” or “Please try to read posts before asking for help” because I have done it all.
This is my current script:
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local JailTimer = player:WaitForChild("prisonFolder"):WaitForChild("jailTimer")
local inPrison = player:WaitForChild("prisonFolder"):WaitForChild("inPrison")
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)
game.ReplicatedStorage.jailEvents.inJail.Event:Connect(function(player)
local JailTimer = player:WaitForChild("prisonFolder"):WaitForChild("jailTimer")
local inPrison = player:WaitForChild("prisonFolder"):WaitForChild("inPrison")
print("Player is prison")
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)
print("character out of jal")
end)
This script only prints “character out of jal” and thats it. I need to know if I need to completely tear town this script & make a new one using the help people provide or I just need to fix certain things. Please tell me because I am out of options.