✓ Accepted answer
Your code should make an error as you have an extra end.
local seat = script.Parent.Saddle
local identifier = script.Parent:WaitForChild('identifier')
seat.Changed:connect(function(property)
local occupant = seat.Occupant
if occupant then
local character = occupant.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if player then
if player.UserId ~= identifier.Value then
character.Humanoid.Sit = false
elseif player.UserId == identifier.Value then
return end
end
end
end
end)
Lastly we should check for what is being changed in the seat then run the code.
Example (updated):-
local seat = script.Parent
local identifier = script.Parent:WaitForChild('identifier')
seat.Changed:connect(function(prop)
if prop == 'Occupant' and seat.Occupant then
local plr = game.Players:GetPlayerFromCharacter(seat.Occupant.Parent)
if plr then
if plr.UserId ~= identifier.Value then
local weld = seat.ChildAdded:Wait()
repeat wait() until weld.Parent
weld:Destroy()
end
else
print('Plr not found')
end
end
end)
The problem with this is that we need to wait for the weld and for it to be a parent of the seat. This process is all managed by roblox so until it has finished we cannot move the player or it will weld the player to the seat even if you make them jump.
I hope this helps.
1 comment
It didn't work. It still prints "Not owner" but doesn't kick the player out of the chair.