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 = Color3.new(163, 162, 165)
local green = Color3.new(0, 200, 0)
script.Parent.Color = white
script.Parent.Material = plastic
local function glowon()
if isTouched == false then
isTouched = true
notTouched = false
end
if isTouched == true then
script.Parent.Color = green
script.Parent.Material = neon
end
end
local function glowoff()
if notTouched == false then
notTouched = true
isTouched = false
end
if notTouched == true then
script.Parent.Color = white
script.Parent.Material = plastic
end
end
platform.Touched:Connect(glowon)
platform.TouchEnded:Connect(glowoff)
So the real question is, What are some Pointers I need to head into the right direction?? Thank you if you read this far
