So how it would work is that the tossed chair on the left is the starting point, and if someone were to sit on the invisible seat around that area, the chair on the ground will disappear and the one that the dummy is sitting on would appear. I don’t have any scripting experience so I could really use some help
Edit: I’m also trying to re-use this script so you would be helping me alot in future projects.
(After rereading your post and seeing that you have no scripting experience, you may want to ask someone elsewhere to make the script for you. This is not a place for hiring.)
local oldchair = chairontheground — change this to the chair laying on the ground
local newchair = chairstandingup — change this to the chair the player is sitting on
local seat = seat — change this to the seat part
seat:GetPropertyChangedSignal(“Occupant”):Connect(function(player)
if player ~= nil then
for i,parts in ipairs(oldchair:GetDecedents()) do
if parts:IsA(“BasePart”) then
parts.Transparency = 1
parts.CanCollide = false
end
end
for i,parts in ipairs(newchair:GetDecedents()) do
if parts:IsA(“BasePart”) then
parts.Transparency = 0
parts.CanCollide = true
end
end
else
for i,parts in ipairs(oldchair:GetDecedents()) do
if parts:IsA(“BasePart”) then
parts.Transparency = 0
parts.CanCollide = true
end
end
for i,parts in ipairs(newchair:GetDecedents()) do
if parts:IsA(“BasePart”) then
parts.Transparency = 1
parts.CanCollide = false
end
end
end
end)
I think this will work. I have no way to test right now. It’s a bit messy cause I had to type it out on my phone
Sadly didn’t work and the problem is location. Where exactly do I place the script? Originally had it in the seat and even with seperating them, I have no luck.
Photos:
It because you haven’t set the variable to the parts. So create a group and put both chair models in that group as well as the script. Then set the new chair variable to script.Parent.NewChair And set the old chair variable to script.Parent.OldChair And set the seat variable to NewChair.Seat
Because you deleted the variables. Just copy an paste this into that script and it should work👍
local oldchair = script.Parent.OldChair
local newchair = script.Parent.NewChair
local seat = newchair.Seat
seat:GetPropertyChangedSignal(“Occupant”):Connect(function(player)
if player ~= nil then
for i,parts in ipairs(oldchair:GetDecedents()) do
if parts:IsA(“BasePart”) then
parts.Transparency = 1
parts.CanCollide = false
end
end
for i,parts in ipairs(newchair:GetDecedents()) do
if parts:IsA(“BasePart”) then
parts.Transparency = 0
parts.CanCollide = true
end
end
else
for i,parts in ipairs(oldchair:GetDecedents()) do
if parts:IsA(“BasePart”) then
parts.Transparency = 0
parts.CanCollide = true
end
end
for i,parts in ipairs(newchair:GetDecedents()) do
if parts:IsA(“BasePart”) then
parts.Transparency = 1
parts.CanCollide = false
end
end
end
end)
local oldchair = script.Parent.OldChair
local newchair = script.Parent.NewChair
local seat = newchair.Seat
seat:GetPropertyChangedSignal(“Occupant”):Connect(function()
local player = seat.Occupant ~= nil and game.Players:GetPlayerFromCharacter(seat.Occupant.Parent)
if player then
for i,parts in ipairs(oldchair:GetDecedents()) do
if parts:IsA(“BasePart”) then
parts.Transparency = 1
parts.CanCollide = false
end
end
for i,parts in ipairs(newchair:GetDecedents()) do
if parts:IsA(“BasePart”) then
parts.Transparency = 0
parts.CanCollide = true
end
end
else
for i,parts in ipairs(oldchair:GetDecedents()) do
if parts:IsA(“BasePart”) then
parts.Transparency = 0
parts.CanCollide = true
end
end
for i,parts in ipairs(newchair:GetDecedents()) do
if parts:IsA(“BasePart”) then
parts.Transparency = 1
parts.CanCollide = false
end
end
end
end)
From what I can see, all you did is remove the “player” variable that the function uses. Please explain the changes you make instead of just saying “you are doing it wrong”.
I see, well if what you said true then I need a little fixing with where I locate things, because I added yours but I’m not sure I placed the seat in the right position to enable the script
Just retype the quotation marks and the stuff within them. For whatever reason when you copy and paste stuff, the script does not register string values (the stuff inside the quotation marks)
Here try this its an edited and updated version of @thebossnnoy
local oldchair = script.Parent:WaitForChild("OldChair")
local newchair = script.Parent:WaitForChild("NewChair")
local seat = newchair:WaitForChild("Seat")
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local player = seat.Occupant and game.Players:GetPlayerFromCharacter(seat.Occupant.Parent)
if player then
for _,parts in pairs(oldchair:GetChildren()) do
if parts:IsA("BasePart") then
parts.Transparency = 1
parts.CanCollide = false
end
end
for _,parts in pairs(newchair:GetChildren()) do
if parts:IsA("BasePart") then
parts.Transparency = 0
parts.CanCollide = true
end
end
else
for _,parts in pairs(oldchair:GetChildren()) do
if parts:IsA("BasePart") then
parts.Transparency = 0
parts.CanCollide = true
end
end
for _,parts in pairs(newchair:GetChildren()) do
if parts:IsA("BasePart") then
parts.Transparency = 1
parts.CanCollide = false
end
end
end
end)