This is for only the person in the seat to close the lapbar and no one else.
the code below here shows what im trying to do.
My code:
local humanoid = script.Parent.Parent.Parent.Seat.Occupant
local character = humanoid.Parent
local player = game.Players:GetPlayerFromCharacter(character)
script.Parent.MouseClick:Connect(function(plr)
if plr.Name == player then
script.Parent.Parent.Parent.Down.Transparency=0
script.Parent.Parent.Transparency=1
script.Parent.Parent.Sound:Play()
script.Parent.MaxActivationDistance=0
end
end)
After that I tested it out and brought back this error:
local Seat = script.Parent.Parent.Parent.Seat -- Path to seat
local character
local player
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if Seat.Occupant ~= nil then
character = Seat.Occupant.Parent
player = game.Players:GetPlayerFromCharacter(character)
end
end)
script.Parent.MouseClick:Connect(function(plr)
if player and plr.Name == player then
script.Parent.Parent.Parent.Down.Transparency=0
script.Parent.Parent.Transparency=1
script.Parent.Parent.Sound:Play()
script.Parent.MaxActivationDistance=0
end
end
local Seat = script.Parent.Parent.Parent.Seat -- Path to seat
local character
local player
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
character = Seat.Occupant.Parent
player = game.Players:GetPlayerFromCharacter(character)
end)
script.Parent.MouseClick:Connect(function(plr)
if player and plr.Name == player.Name then
script.Parent.Parent.Parent.Down.Transparency=0
script.Parent.Parent.Transparency=1
script.Parent.Parent.Sound:Play()
script.Parent.MaxActivationDistance=0
end
end
local humanoid = script.Parent.Parent.Parent.Seat.Occupant
local character = humanoid.Parent
local player = game.Players:GetPlayerFromCharacter(character)
script.Parent.MouseClick:Connect(function(plr)
if plr.Name == player.Name then
script.Parent.Parent.Parent.Down.Transparency=0
script.Parent.Parent.Transparency=1
script.Parent.Parent.Sound:Play()
script.Parent.MaxActivationDistance=0
end
end)