Hi. I’m trying to make it so that if a player that doesn’t own the vehicle enters the driver seat then they get kicked but it doesn’t work.
Script:
local ownerValue = script.Parent.Parent.Parent.Parent.Owner
local seat = script.Parent
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
print("Property changed")
if seat.Occupant and seat.Occupant.Name ~= ownerValue.Value then
seat.Occupant.Jump = true
end
end)
and the ownerValue is set manually so it’s not a problem with it being changed on the client side.
In fact it doesn’t even print the property changed"
where is this script located? Is it a local or a server script? Also print the ownerValue and see what it returns. The value also has to be set on the server. Possibly a remote event can do that if you change it on the client.
What script kicks the player out? Check owner right?
EDIT:
I think I know the problem, its on this line:
Your checking the occupants name, but the occupant is the humanoid, not the character, so to fix this, you can replace it with:
if seat.Occupant and seat.Occupant.Parent.Name ~= ownerValue.Value then
I also changed some bits up, because I was testing in studio, full code:
local ownerValue = "JAcoboiskaka1122"
local seat = script.Parent
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
print("Property changed")
if seat.Occupant and seat.Occupant.Parent.Name ~= ownerValue then
print("Occupant found")
task.wait(0.1)
seat.Occupant.Jump = true
end
end)
print("ownerValue =", ownerValue.Value)
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if not seat.Occupant then return end
if seat.Occupant.Parent.Name ~= ownerValue.Value then
task.wait(1)
seat.Occupant.Sit = false
end
end)