Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can i make this blinking script work? I really want to know how for i am new to scripting.

Asked by 6 years ago
Edited 6 years ago

I'm trying to make a person blink And I tried to do it but it didn't work. (There faces dont use decals they use parts)

Blink = Game.Parent
while true do
wait 5
Blinking = math.random(1,5)
if Blinking == 1 then
Blink.Transparency = 1
end
if Blinking == 2 then
Blink.Transparency = 0
end
if Blinking == 3 then
Blink.Transparency = 1
end
if Blinking == 4 then
Blink.Transparency = 1 
end
if Blinking == 5 then
Blink.Transparency = 0
end

What did i do wrong? I have no idea cause I'm new to scripting.

Also if you want to see the face of the person that I'm trying to make blink then check it out here. https://www.roblox.com/games/1366389432/Plastic-World-Testing

1 answer

Log in to vote
0
Answered by 6 years ago

So there is two things we will have to change to make it work and one thing to change to make your code pretty.

The first is that you set Blink to the parent of the Game with Blink = Game.Parent. I'm going to guess that if this is a part then it is not the parent of the game, but the parent of the script. We will want to change our script to read.

Blink = script.Parent

Now if the script is placed so that it's parent is the block then it will start blinking in transparency.

The other thing is that we have to add one more end at the end so that we end both the if statement and the while loop. Here's your code with those changes applied.

Blink = script.Parent
while true do
wait(5) -- This is my cosmetic change that I mentioned! This is a comment.
Blinking = math.random(1,5)
if Blinking == 1 then
Blink.Transparency = 1
end
if Blinking == 2 then
Blink.Transparency = 0
end
if Blinking == 3 then
Blink.Transparency = 1
end
if Blinking == 4 then
Blink.Transparency = 1 
end
if Blinking == 5 then
Blink.Transparency = 0
end
end -- Added an end here. This is also a comment.
0
Thanks. I also added a wait after the block appears and made the wait 0.2 and i made the eyes open again after that wait. Its so the eyes don't stay closed for a while. That's not really blinking is it? CookiethBoy 6 — 6y
0
What is in a blink? I think that behaviour works just fine. User#18718 0 — 6y
0
Remember to mark the answer as accepted if it worked. User#18718 0 — 6y
Ad

Answer this question