For some reason my datastore is returning " " and I keep getting errors about an attempt to compare a string with a number.
Code:
local DSS = game:GetService("DataStoreService") ArrestDS = DSS:GetDataStore("Arrest") game.Players.PlayerAdded:Connect(function(plr) local plra = Instance.new("StringValue") plra.Name = plr.Name plra.Parent = script.Folder local Time = ArrestDS:GetAsync(plr.Name .. ":" .. plr.UserId) print(Time) if Time == " " or Time == nil or Time == "" then ArrestDS:SetAsync(plr.Name .. ":" .. plr.UserId, tonumber(0)) elseif Time > 0 then local jailgui = script.JailUI:Clone() jailgui.Parent = plr.PlayerGui plr.TeamColor = BrickColor.new("Magenta") end end) game.ReplicatedStorage.Cuffs.OnServerEvent:Connect(function(plr, otherplr, state, arresttime) if state == "Cuff" then script.Folder:FindFirstChild(plr.Name).Value = otherplr cuff(plr, otherplr) elseif state == "Uncuff" then script.Folder:FindFirstChild(plr.Name).Value = "" uncuff(plr, otherplr) end if state == "Arrest" then local jailgui = script.JailUI:Clone() jailgui.Parent = game.Players[otherplr].PlayerGui game.Players[otherplr].TeamColor = BrickColor.new("Magenta") ArrestDS:SetAsync(otherplr .. ":" .. game.Players[otherplr].UserId, arresttime) while wait(1) do local success = pcall(function() return ArrestDS:IncrementAsync(otherplr .. ":" .. game.Players[otherplr].UserId, -1) end) print(ArrestDS:GetAsync(otherplr .. ":" .. game.Players[otherplr].UserId)) end end end) function cuff(plr,otherplr) game.Workspace[otherplr].Torso.Anchored = true game.Workspace[otherplr].Torso.CanCollide = false game.Workspace[otherplr].Head.CanCollide = false game.Workspace[otherplr].Torso.Anchored = false while script.Folder:FindFirstChild(plr.Name).Value == otherplr do wait(0.00000001) game.Workspace[otherplr].Torso.CFrame = game.Workspace[plr.Name].Torso.CFrame * CFrame.new(0,0,-2.5) end end function uncuff(plr,otherplr) game.Workspace[otherplr].Torso.CanCollide = true game.Workspace[otherplr].Head.CanCollide = true end