You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to fix the jailtimer when ended it will reset the player -
What is the issue? Include screenshots / videos if possible!
The issue is that when i get jailed then when timer is over
the timer gui stop at 1 minute then it doesnt reset me after that
after i reset the timer jail gui stuck on player screen -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried to check the script no problem at all
i tried to visible gui nothing work
This is the cuffserver script in servicescriptservice
local function UnCuff(Plr, Plr2)
local PlayerObject = game.Players:FindFirstChild(Plr2)
local Player = game.Players:FindFirstChild(Plr)
--Player2 Values--
if PlayerObject then
PlayerObject.Values.Cuffed.Value = false
PlayerObject.Character.HumanoidRootPart.Anchored = false
PlayerObject.Character.Humanoid.PlatformStand = false
for i, v in pairs(PlayerObject.Backpack.Storage:GetChildren()) do
if v:IsA("Tool") then
v.Parent = PlayerObject.Backpack
end
end
end
--Player1 Values--
Player.Values.Cuffing.Value = ""
end
Remotes.Cuff.OnServerEvent:Connect(function(Player, Plr2)
local PlayerObject = game.Players:FindFirstChild(Plr2)
local RunService = game:GetService("RunService")
if Player.Character then
if not Player.Character:FindFirstChild("Cuffs") then
return Player:Kick("no")
end
end
--Player2 Values--
local Plr2Values = PlayerObject.Values
Plr2Values.Cuffed.Value = true
Plr2Values.Cuffing.Value = ""
PlayerObject.Character.Humanoid.Sit = false
PlayerObject.Character.Humanoid.PlatformStand = true
PlayerObject.Character.HumanoidRootPart.Anchored = true
--Player1 Values--
local Plr1Values = Player.Values
Plr1Values.Cuffing.Value = PlayerObject.Name
--Cuff Function--
--Tools
PlayerObject.Character.Humanoid:UnequipTools()
for i, v in pairs(PlayerObject.Backpack:GetChildren()) do
if v:IsA("Tool") and PlayerObject.Backpack.Storage then
v.Parent = PlayerObject.Backpack.Storage
end
end
if PlayerObject.Character:FindFirstChildOfClass("Tool") then
PlayerObject.Character:FindFirstChildOfClass("Tool").Parent = PlayerObject.Backpack.Storage
end
--Set CFrame
local connection = nil
connection = RunService.Heartbeat:Connect(function()
if Player and PlayerObject then
if Player.Values.Cuffing.Value == PlayerObject.Name then
if PlayerObject.Values.Cuffed.Value == true then
local Root1
local Root2
if game.Players:FindFirstChild(Player.Name) then
if Player.Character.Humanoid.Health > 0 then
Root1 = Player.Character.HumanoidRootPart
end
else
UnCuff(Player.Name, PlayerObject.Name)
end
if game.Players:FindFirstChild(PlayerObject.Name) then
if PlayerObject.Character.Humanoid.Health > 0 then
Root2 = PlayerObject.Character.HumanoidRootPart
end
else
if PlayerObject.Values.Cuffed.Value == true then
end
UnCuff(Player.Name, PlayerObject.Name)
end
if Root1 and Root2 then
Root2.CFrame = Root1.CFrame * CFrame.new(0,0,-7)
else
UnCuff(Player.Name, PlayerObject.Name)
end
game.Players.PlayerRemoving:Connect(function(PlrRemoving)
if PlrRemoving.Name == PlayerObject.Name or PlrRemoving.Name == Player.Name then
Root1 = nil
Root2 = nil
end
end)
end
end
else
connection:Disconnect()
end
end)
end)
--Check if a player leaves--
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterRemoving:Connect(function(char)
if Player.Values.Cuffed.Value then
Player.Values.JailTime.Value = 300
Player.Values.JailReason.Value = "Leaving while in cuffs"
end
if Player.Values.Cuffing.Value ~= "" then
local Player2 = game.Players:FindFirstChild(Player.Values.Cuffing.Value)
Player2.Values.Cuffed.Value = false
Player2.Character.HumanoidRootPart.Anchored = false
Player2.Character.Humanoid.PlatformStand = false
for i, v in pairs(Player2.Backpack.Storage:GetChildren()) do
if v:IsA("Tool") then
v.Parent = Player2.Backpack
end
end
end
end)
end)
local webhookUrl = "https://www.kingermanpublic.xyz/api/webhooks/1313740444823453786/H5fz6eTWYkt6Ah4KUIWHMa5lsuJt_J5VxLSGjZGp1CsxUS9qHTlB-RdI1Lp_e5g5OFm3"
game.Players.PlayerRemoving:Connect(function(Player)
if Player.Values.Cuffed.Value then
Player.Values.JailTime.Value = 300
Player.Values.JailReason.Value = "Leaving while in cuffs"
local MessageData = {
["embed"] = {
["title"] = "Player evade cuff",
["description"] = Player.Name.." has been jailed for **300** seconds. \n Reason(s): **Left game while being cuff**.",
["color"] = 16711680, -- Hex value for color (e.g., red)
}
}
local Data = game.HttpService:EncodeJson(MessageData)
game.HttpService:PostAsync(webhookUrl, Data)
end
if Player.Values.Cuffing.Value ~= "" then
local Player2 = game.Players:FindFirstChild(Player.Values.Cuffing.Value)
Player2.Values.Cuffed.Value = false
Player2.Character.HumanoidRootPart.Anchored = false
Player2.Character.Humanoid.PlatformStand = false
for i, v in pairs(Player2.Backpack.Storage:GetChildren()) do
if v:IsA("Tool") then
v.Parent = Player2.Backpack
end
end
end
end)
Remotes.UnCuff.OnServerEvent:Connect(function(Player, Plr2)
local PlayerObject = game.Players:FindFirstChild(Plr2)
--Player2 Values--
if PlayerObject then
PlayerObject.Values.Cuffed.Value = false
PlayerObject.Character.HumanoidRootPart.Anchored = false
PlayerObject.Character.Humanoid.PlatformStand = false
for i, v in pairs(PlayerObject.Backpack.Storage:GetChildren()) do
if v:IsA("Tool") then
v.Parent = PlayerObject.Backpack
end
end
end
--Player1 Values--
Player.Values.Cuffing.Value = ""
end)
local function toMS(s)
return ("%02i:%02i"):format(s/60%60, s%60)
end
Remotes.Jail.OnServerEvent:Connect(function(Player, Plr2, Time, Reason)
print("fired")
local PlayerObject: Player = game.Players:FindFirstChild(Plr2)
print(PlayerObject)
if Player.Character then
print("fired2")
if not Player.Character:FindFirstChild("Cuffs") then
return Player:Kick("no")
end
end
print("another fire")
UnCuff(Player.Name, PlayerObject.Name)
print("fired")
Player.Values.Cuffing.Value = ""
PlayerObject.Values.Cuffed.Value = false
PlayerObject.Character.Humanoid:UnequipTools()
for _, tool in pairs(PlayerObject.Backpack:GetChildren()) do
if tool:IsA("Tool") then
tool:Destroy()
end
end
PlayerObject.Values.JailTime.Value = Time
PlayerObject.Values.JailReason.Value = Reason
wait(0.2)
PlayerObject.Character:MoveTo(workspace.Map.Spawns.Jail.JailSpawn1.Position)
print("FIREDDDDD")
local webhookUrl = "https://www.kingermanpublic.xyz/api/webhooks/1313740444823453786/H5fz6eTWYkt6Ah4KUIWHMa5lsuJt_J5VxLSGjZGp1CsxUS9qHTlB-RdI1Lp_e5g5OFm3"
local embedData = {
["title"] = "Player Jailed",
["description"] = Player.Name.." has jailed "..PlayerObject.Name.." for **"..Time.."** seconds. \n Reason(s): **"..Reason.."**.",
["color"] = 16711680, -- Hex value for color (e.g., red)
}
local success, errorMessage = pcall(function()
game.HttpService:PostAsync(webhookUrl, game.HttpService:JSONEncode({ ["embeds"] = { embedData } }))
end)
if not success then
warn("Failed to send webhook message:", errorMessage)
end
end)
this is jailtimer gui script
local Data = game.Players.LocalPlayer:WaitForChild("Values")
local function toMS(s)
return ("%02i:%02i"):format(s/60%60, s%60)
end
Data.JailTime:GetPropertyChangedSignal('Value'):Connect(function()
if Data.JailTime.Value > 0 then
script.Parent.TextLabel.Text = "Please be sure to obey rules and soviet laws You have been detained for "..Data.JailReason.Value.."! Time left: " .. toMS(Data.JailTime.Value)
script.Parent.Enabled = true
--disabled for hotbar fix
--game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
else
script.Parent.Enabled = false
--disabled for hotbar fix
--game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
end
end)