So, The script just stops when the scripts reaches line "39" and "44" why it is like the script dosent know when you sit down on the seat even if it should do that why does it do that. So the script can't run that line at "39" when you sit down and "44" if you jump off the seat anyone knows why it does this? it is no errors in the output
Here is the script and it is a MainScript not a localscript:
--------------- BOX SYSTEM -----------------------------------------------
local systemName = "Boxes"
local BoxName = "Standard"
local sitDetector = require(game.ServerScriptService.SitDetector)
local boxes = {}
function _G.GetBoxFromPart(part)
for b,_ in pairs(boxes) do
if (part:IsDescendantOf(b)) then
return b
end
end
end
function SetupSystem(g)
local copy = g[BoxName]:Clone()
local function CreateSitDetector(Standard)
local detector = sitDetector:Create(Standard.Seat)
detector.PlayerSit:connect(function(plr)
print("h")
Standard.Player.Value = plr
game.ReplicatedStorage.ClientRequest.GiveControl:InvokeClient(plr, Standard)
end)
detector.PlayerStand:connect(function(plr)
Standard.Player.Value = nil
plr.Character.Humanoid.Health = 0
game.ReplicatedStorage.ClientRequest.RemoveControl:InvokeClient(plr, Standard)
end)
end
CreateSitDetector(g[BoxName])
local function Regen()
local newBox = copy:Clone()
newBox.Parent = g
newBox:MakeJoints()
boxes[newBox] = true
CreateSitDetector(newBox)
end
Regen(playersInRound)
end
local function FindSystem()
for _,v in pairs(game.ReplicatedStorage:GetChildren()) do
if (v:IsA("Folder") and v.Name == systemName) then
SetupSystem(v)
end
end
end
FindSystem()
-----------------------------------------------------------------------
