-
What do you want to achieve? Hello, i want to make blink a part color, like going to red then going to black then going to red
-
What is the issue? I can’t manage to do it.
-
What solutions have you tried so far? I looked on forums and tried myself.
local part = "Put the part location here"
while true do
part.Brickcolor = "Really Red"
wait(.2)
part.Brickcolor = "Really Black"
wait(.2)
end
I know that solution but it’s not efficient and i can’t do it in a running code
wdym by running code bruh, just put it in a serverscript
I need to make the part blink in an already running code, in a function, and it’s not efficient
Changed @lV0rd code so it’s better, while loops are very bad practices, if you want to use them tho, use courotines so It doesn’t stop the rest of the script.
local runService = game:GetService("RunService")
local part = --path to part
runService.Heartbeat:Connect(function() --you might need to change heartbeat according to the script your using.
part.BrickColor = "Really Red"
wait(.2)
part.BrickColor = "Really Black"
wait(.2)
end)
Thank you, but how can i make it blink when i want, i don’t want the part to always blink
you have got to be kidding me.
2 Likes
local part = script.Parent --put the location of the part in this variable
function Blinking()
while true do
part.BrickColor = "Really Red"
wait(.2)
part.BrickColor = "Really Black"
wait(.2)
end
end
task.spawn(Blinking) -- Run this when you want to start it
1 Like
he doesnt want it to be a loop afaik
local part = script.Parent --put the location of the part in this variable
function Blink()
local blinkLength = .2 -- how long to blink for
task.spawn(function()
part.BrickColor = BrickColor.new("Really Black")
task.wait(blinkLength)
part.BrickColor = BrickColor.new("Really Red")
end)
end
-- Call Blink() in your code whenever
so this should do fine
1 Like
isn’t that the same thing as i did?
Ye but task.spawn allows it to run without stopping code
just told him how to use your code
1 Like
You can also use bind and unbind aswell.
local runService = game:GetService("RunService")
local part = --path to part
local blink = true
local delayBetweentBlinks =. 2
runService.Heartbeat:Connect(function() --you might need to change heartbeat according to the script your using.
if not blink the return end
part.BrickColor = "Really Red"
wait(delayBetweentBlinks)
part.BrickColor = "Really Black"
wait(delayBetweentBlinks)
end)