I’m trying to make a seat that doesn’t allow you to sit unless you have a certain boolean value set to true, Which is called “Can Sit”.
The default is false and when I test it(I made sure my value is set to false) it doesn’t kick me off the seat.
script.Parent.ChildAdded:Connect(function(Seat)
if Seat.Name == "SeatWeld" and Seat:IsA("Weld") then
local Player = game.Players:GetPlayerFromCharacter(Seat.Part1.Parent)
if Player["Can Sit"] == false then
Seat:Destroy()
end
end
end)
It doesn’t output any errors from this script, any help will be appreciated!
I think I got the Idea of what you meant, here’s what I wrote based on your suggestion:
script.Parent.ChildAdded:Connect(function(Seat)
if Seat.Name == "SeatWeld" and Seat:IsA("Weld") then
local Player = game.Players:GetPlayerFromCharacter(Seat.Part1.Parent)
if Player["Can Sit"] == false then
Seat.Part1.Parent:FindFirstChild("Humanoid").Sit = false
end
end
end)
you could check for .PropertyChanged on the seat, because the occupant property of a chair/vehicle seat will always be the Character model that is in the chair, then tell the character’s humanoid to jump on sit if that value is false.
script.Parent.PropertyChanged:Connect(function(Seat)
if Seat.Name == "SeatWeld" and Seat:IsA("Weld") then
local Player = game.Players:GetPlayerFromCharacter(Seat.Part1.Parent)
if Player["Can Sit"] == false then
Seat.Part1.Parent:FindFirstChild("Humanoid").Sit = false
end
end
end)
So, to start, why dont you put Print() statements on a few lines to see where it stops.
for ex.
script.Parent.PropertyChanged:Connect(function(Seat)
if Seat.Name == "SeatWeld" and Seat:IsA("Weld") then
local Player = game.Players:GetPlayerFromCharacter(Seat.Part1.Parent)
Print("test#2")
if Player["Can Sit"] == false then
Seat.Part1.Parent:FindFirstChild("Humanoid").Sit = false
Print("testing")
end
end
end)