Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a seat that only first person who sat can sit in?

Asked by 6 years ago

I'm making a car game and I want to make a script that will jump someone if they weren't the first person to sit in the car. How do I do that?

1 answer

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago

Try this:

local car = script.Parent
local seat = car.Seat
local playerwhosatfirst

seat:GetPropertyChangedSignal('Occupant'):Connect(function(hum)
    if not playerwhosatfirst then
        playerwhosatfirst = game.Players:GetPlayerFromCharacter(hum.Parent)
    elseif playerwhosatfirst and playerwhosatfirst ~= game.Players:GetPlayerFromCharacter(hum.Parent) then
        hum.Jump = true
    end
end)
Ad

Answer this question