Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Part effects work when part is sat on/not sat on, but when other part sat on effects glitch [EASY]?

Asked by
Vid_eo 126
7 years ago

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:

01script.Parent.Seat.Touched:connect(function(hit)
02    while wait() do
03    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
04        if player.Character.Humanoid.Sit == true then
05            for i,v in pairs (script.Parent.Model:GetChildren()) do
06                if v:IsA("BasePart") then
07                    v.Material = "Neon"
08                end
09            end
10        end
11            if player.Character.Humanoid.Sit == false then
12                for i,v in pairs (script.Parent.Model:GetChildren()) do
13                    v.Material = "SmoothPlastic"
14                end
15        end
16    end
17end)

Thanks!

0
Can you please post a screen shot of what this is doing so I can understand myself SynthetickDev 188 — 7y
0
When a player sits on one of these parts, it turns neon: https://gyazo.com/b01f950a6b7b581e9bac9318c164f02d. When they get off, it turns smoothplastic. Vid_eo 126 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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

0
Thanks! Vid_eo 126 — 7y
Ad

Answer this question