So i want the player sitting on the chair1 to be the only one that can click on the brick.. So that it changes another brick's materials and colors..
I tried outputting both the clicker name and the occupant of the seat... They both display the same result...However the comparison will not work, i.e the instructions within if Clicker.Name==occupied.Parent then
local x1 --the model that is supposed to change color & material
script.Parent.ClickDetector.MouseClick:Connect(function(Clicker)
local occupied=game.Workspace.Chair1.Seat.Occupant
if occupied==nil then
--print("no one is sitting")
else
print(Clicker.Name)
print(occupied.Parent)
if Clicker.Name==occupied.Parent then
print("WORKING???")
x1=game.Workspace.x1:GetChildren()
for i=1,3 do
x1[i].Material="Neon"
x1[i].BrickColor=BrickColor.new("Really red")
end
end
end
end)
EDIT : so i just realised occupied.parent is a userdata value

2 comments
Okay..So i just had to convert the userdata value into string and it works
A ClickDetector MouseClick passes the player character. You can also use https://developer.roblox.com/api-reference/function/Players/GetPlayerFromCharacter as occupied.Parent would be the char model.