How can i fix this issue? ROBLOX

33 Views Asked by At

whenever i spawn at the right (the encircled part) the parts that i circled on the left dont work. Whats supposed to be happening is that whenever u press e the black parts disappear and the white parts appear and vice versa. but then when i spawn on the left side where i circled it those aprts that didnt work now suddenly work. i put both the black and white parts in seperate folders and i tried waiting at the spawn for like aminute to see if the problem is that the parts arent loading but it doesnt work

heres my code

local Parts2 = workspace.TestFolder2:GetChildren()

local TweenService = game:GetService("TweenService")
local Tweeninfo = TweenInfo.new(
    0.1,
    Enum.EasingStyle.Linear,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)
local goal = {
    Transparency = 1
}
local goal2 = {
    Transparency = 0
}

local GameCharacter = game.StarterPlayer.StarterCharacter
local UIS = game:GetService("UserInputService")
local BodyColors = GameCharacter["Body Colors"]
local Colors = BodyColors:GetChildren()
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character
local Black = character.White.Value
local White = character.White.Value



UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.E then
        if character.Head.BrickColor == BrickColor.new("Really black") then
            print("its black")
            character.Head.BrickColor = BrickColor.new("Institutional white")
            BodyColors.HeadColor = BrickColor.new("Institutional white")
            character["Left Arm"].BrickColor = BrickColor.new("Institutional white")
            character["Right Arm"].BrickColor = BrickColor.new("Institutional white")
            character["Right Leg"].BrickColor = BrickColor.new("Institutional white")
            character["Left Leg"].BrickColor = BrickColor.new("Institutional white")
            character.Torso.BrickColor = BrickColor.new("Institutional white")
            for i, v in pairs(Parts)do
                local Tween = TweenService:Create(v, Tweeninfo, goal)
                Tween:Play()
                
                v.CanCollide = false
            end
            for i, v in pairs(Parts2)do
                local Tween = TweenService:Create(v, Tweeninfo, goal2)
                Tween:Play()

                v.CanCollide = true
            end
        elseif character.Head.BrickColor == BrickColor.new("Institutional white") then
            print("Its white now")  
            character.Head.BrickColor = BrickColor.new("Really black")
            BodyColors.HeadColor = BrickColor.new("Really black")
            character["Left Arm"].BrickColor = BrickColor.new("Really black")
            character["Right Arm"].BrickColor = BrickColor.new("Really black")
            character["Right Leg"].BrickColor = BrickColor.new("Really black")
            character["Left Leg"].BrickColor = BrickColor.new("Really black")
            character.Torso.BrickColor = BrickColor.new("Really black")
            for i, v in pairs(Parts)do
                local Tween = TweenService:Create(v, Tweeninfo, goal2)
                Tween:Play()

                v.CanCollide = true
            end
            
            for i, v in pairs(Parts2)do
                local Tween = TweenService:Create(v, Tweeninfo, goal)
                Tween:Play()

                v.CanCollide = false
            end
        end
        
        
        
    end
    
end)

while true do
    wait(1) 
    White = true
end```
0

There are 0 best solutions below