I’ve tried to make a check with the A1_a1, but ofc, when a new player sits down that player becomes A1_a1. I’ve tried using Developer Wikia, but haven’t found anything to help me. I’m really stuck, and anything would be helpful, thanks.
well you can count how many times it was touched and fidn the player who added the first 1 to the variable,like so
local Player = game.Players.LocalPlayer
local Players = game.Players
local touched = 0
script.Parent.Touched:Connect(function(hit)
touched.Value = touched.Value +1
if hit.Parent == Players then
-- whatever down here
end)
as this might not be right this is just a prime example
I got a bit confused over the title and what you are actually asking.
You might want to rename it to something like “Lock seat to other players” or something.
Either way, you can do it:
Saving which player sat first, and make anyone jump if they’re not the original player (like Usering said)
You could disable the seat for the server(server script), which will replicate to every client. After so, enable it back for the client using a localscript
Or like someone also said, enable/disable it according to who touched the seat.
Add a changed event to the seat and if someone sits in it you make them the owner, if another person sits on it and isn’t you force them to get back up.
(This script isn’t going to work if you paste it into the seat, it’s just an example of what you would do)
local owner = nil
seat.Changed:Connect(function()
if seatOwner then
newHumanoid.Sit = false
elseif owner == nil then
owner = humanoid
end
end)
I wrote this up real quick given how OP wanted the system to work. Wasn’t able to test, but this should work in theory
local seat = workspace.Seat
local originalOccupant
local lastTouch = 0
seat.Touched:connect(function(hit)
if tick() - lastTouch > 2 then
lastTouch = tick()
local hum = hit.Parent and hit.Parent:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and hum then
if not originalOccupant then
originalOccupant = player
elseif originalOccupant ~= player then
return
end
seat:Sit(hum)
end
end
end)