Log in to vote

Materials not Changing and Flickering Colors/Materials??

Asked by 13 days ago

I am extremely new to scripting, and I'm trying to make a simple code where; The Player hops on Platform, Platform changes Color and Material while the Player is on the Platform. Once the Player is off the Platform, it changes back to the Normal Color and Material.

I have semi-accomplished this; however, 2 problems I have is that 1.) It keeps flickering between the colors/materials as I'm walking, but it works EXACTLY as intended if I just hop on and keep still and 2.) The Material won't change to Neon, but the colors change successfully

Here is said code;

local platform = script.Parent                      
local material = script.Parent.Material         
local color = script.Parent.Color               

local isTouched = false                         
local notTouched = true                         

local plastic = Enum.Material.Plastic           
local neon = Enum.Material.Neon                 

local white =, 162, 165)         
local green =, 200, 0)             

script.Parent.Color = white                     
script.Parent.Material = plastic                

local function glowon()                         
    if isTouched == false then                      
        isTouched = true                            
        notTouched = false                          

    if isTouched == true then                       
        script.Parent.Color = green                 
        script.Parent.Material = neon               

local function glowoff()                        
    if notTouched == false then                     
        notTouched = true                           
        isTouched = false                           

    if notTouched == true then                      
        script.Parent.Color = white                 
        script.Parent.Material = plastic        


So the real question is, What are some Pointers I need to head into the right direction?? Thank you if you read this far

Answer this question