I am trying to have a block switch colors back and forth slowly. Here is my Script.
Game1 = game.ReplicatedStorage.G1
local fx = math.random(-101,-5)
local fz = math.random(-47,51)
local fart = Instance.new("Part",workspace)
fart.CFrame = CFrame.new(fx,2,fz)
fart.Parent = nil
fart.BrickColor = BrickColor.Red()
fart.Anchored = true
local TweenService = game:GetService("TweenService")
local info = TweenInfo.new(1)
local goal = {}
goal.Color = Color3.new(0,0,0)
function play()
if Game1.Value == 1 then
repeat
fart.Parent = workspace
fz = math.random(-47,51)
fx = math.random(-101,-5)
fart.CFrame = CFrame.new(fx,2,fz)
local Tween = TweenService:Create(fart, info, goal)
Tween:Play()
goal.Color = Color3.new(255,0,0)
wait(1)
local Tween = TweenService:Create(fart, info, goal)
print("red")
Tween:Play()
goal.Color = Color3.new(0,0,0)
wait(1)
until Game1.Value == 0
end
if Game1.Value == 0 then
fart.Parent = nil
end
end
Game1:GetPropertyChangedSignal("Value"):Connect(play)
However, what happens is shown in the video below.
The block just oscillates from red to black super fast and for some reason stays black for a majority of the time. Why is this?