Issues with making a part change material during an event

Basically, I want this part to go from neon to plastic back and forth to simulate a beeping effect during an event.

This is the things I want:

1-Beep.
2- If also possible could this script could only last for 15 seconds and then the part goes back to plastic.

And this is the script I attempted.

if game.Workspace.Values.startup.Value == true then
	script.Parent.Material = Enum.Material.SmoothPlastic 
	wait(0.5) 
	script.Parent.Material = Enum.Material.Neon 
	wait(0.5)
end

Cheers, thank you.

Try this script.

local Startup = game.Workspace.Values.startup

function ChangeState()
script.Parent.Material = Enum.Material.SmoothPlastic
wait(0.5)
script.Parent.Material = Enum.Material.Neon
wait(15)
script.Parent.Material = Enum.Material.SmoothPlastic
Startup.Value = false
end

if Startup.Value == true then
ChangeState()
end

Startup.Changed:connect(function(NewVal)
if NewVal == true then
ChangeState()
end
end)

while game.Workspace.Values.startup.Value do
	script.Parent.Material = Enum.Material.SmoothPlastic 
	task.wait(0.5) 
	script.Parent.Material = Enum.Material.Neon 
	task.wait(0.5)
end

Thanks bro! Will check this out right now!

And there we go, it worked thank you.

1 Like

Hey one more question, I have made another value for a startup failure. I wanted to know how to select a random number as a start up failure and a normal start up. How do I do a script like this.

So far, this is my current progress of a script.

Basically, I want the normal start up to have an higher chance then failedstartup.

local chance = math.random(0,50)
	if chance == 1 then
		game.Workspace.Values.FailureStartup.Value = true
	end

Try this

local chance = math.random(0,100)
	if chance <= 60  then
		game.Workspace.Values.FailureStartup.Value = true
	end

You can change the number 60 to how easy you want normal startup to run, rn its set to 60 which means it will have a 60% chance of running, the higher you set that number = the higher the chance :grinning: Hope this helped!

1 Like

Thanks bro! Really needed this one!

1 Like