For some reason, when I sit on a part and then get off of it the script works fine, but when I sit on another part, both the part that I had previously sat on and the part that I am now sitting on light up; https://gyazo.com/904a430766537e96d97ca06de386597d (photo of the hierarchy)
CODE:
script.Parent.Seat.Touched:connect(function(hit) while wait() do local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player.Character.Humanoid.Sit == true then for i,v in pairs (script.Parent.Model:GetChildren()) do if v:IsA("BasePart") then v.Material = "Neon" end end end if player.Character.Humanoid.Sit == false then for i,v in pairs (script.Parent.Model:GetChildren()) do v.Material = "SmoothPlastic" end end end end)
Thanks!
I see your problem you are not ending the 'while' loop, so it is going to check if the player is sitting or not forever, you need to find a place to add a 'break' in there so that the while loop stops