So i’m trying to make a script that will put player who joined the game to a random seat, and they can’t jump/ get out the seat.
here is the example of 2 seats that i made:
local Players = game:GetService("Players")
local S1 = script.Parent.Sit1
local S2 = script.Parent.Sit2
local check1 = false
local check2 = false
function setseat(player) -- check when player join the game
local character = player.Character or player.CharacterAdded:Wait()
local hm = character:FindFirstChildOfClass("Humanoid")
character.Humanoid.JumpPower = 0
if hm then
if check1 == false then
wait(1)
S1:sit(hm)
check1 = true
else
if check2 == false then
wait(1)
S2:sit(hm)
check2 = true
end
end
end
end
Players.PlayerAdded:Connect(setseat)
Players.PlayerRemoving:Connect(function() -- reset the seat for other player to join
S1:GetPropertyChangedSignal("Occupant"):Connect(function()
if S1.Occupant == nil then
check1 = false
end
end)
S2:GetPropertyChangedSignal("Occupant"):Connect(function()
if S2.Occupant == nil then
check2 = false
end
end)
end)
but when i tried to run the game, sometime it’s work ( 2 player with 2 different seat), but sometime it doesn’t (1 player sit, and the other not), and i’m not sure how to fix, can someone please help me, i would really appreciate your help (sorry if you can’t understand what i try to say, i’m not really good at english)
thanks for reading.