Hi, I’m making a camping van, but I want all players to go to a specific seat, I have the code, how would I do that?
Code:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Seats = game.Workspace.Seats:GetChildren()
local Debounce = false
local Player = game.Players:GetPlayerFromCharacter(script.Parent)
game.Workspace.Part.Touched:Connect(function(Touch)
if Touch.Parent:FindFirstChild("Humanoid") then
if game.Players:FindFirstChild(Touch.Parent.Name) then
if Debounce == false then
Debounce = true
local SeatChosen = Seats[1]
SeatChosen:Sit(Touch.Parent.Humanoid)
ReplicatedStorage.Insert:FireServer(true, SeatChosen)
local ExitGUI = ReplicatedStorage.SeatExit:Clone()
ExitGUI.Parent = Player.PlayerGui
ExitGUI.MainFrame.ExitBtn.MouseButton1Click:Connect(function()
print("Clicked!")
ReplicatedStorage.Jump:InvokeServer()
ExitGUI:Destroy()
Debounce = false
ReplicatedStorage.Insert:FireServer(false, SeatChosen)
end)
end
end
end
end)
Server:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
ReplicatedStorage.Jump.OnServerInvoke = function(Player)
local Character = Player.Character
local Humanoid = Character.Humanoid
Humanoid.Jump = true
wait(.7)
Character:SetPrimaryPartCFrame(CFrame.new(game.Workspace.Part2.Position + Vector3.new(0, 5, 0)))
end
local InSeats = {}
local Seats = game.Workspace.Seats:GetChildren()
ReplicatedStorage.Insert.OnServerEvent:Connect(function(Player, Sign, chosenSeat)
if Sign == true then
table.insert(InSeats, Player)
print("Inserted!")
print(#InSeats)
table.remove(Seats, 1)
elseif Sign == false then
for i, v in pairs(InSeats) do
if v.Character.Humanoid == Player.Character.Humanoid then
table.remove(InSeats, i)
print("Booted out!")
print(#InSeats)
table.insert(Seats, chosenSeat)
end
end
end
end)