Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script makes everything beyond "Right" invisible, Any help?

In the script below, it just makes stuff appear and reappear. However, It just goes invisible, and the right just reappears. How do i fix this? Side question: How do i make the character do a animation when something is clicked, like a click detector? thanks for any help!

function onClick(player)

player.Character.Right.Transparency = 1

  

print("HOZAY")

wait(1)

player.Character.Right1.Transparency = 0

player.Character.Right1.Transparency = 1

wait(1)

player.Character.Right2.Transparency = 0

player.Character.Right2.Transparency = 1

wait(1)

player.Character.Right3.Transparency = 0

player.Character.Right3.Transparency = 1

wait(1)

player.Character.Right4.Transparency = 0

player.Character.Right4.Transparency = 1

wait(1)

player.Character.Right.Transparency = 0

  

  

  

end

script.Parent.ClickDetector.MouseClick:Connect(onClick)

1 answer

It's not clear exactly how you want it to work, but I will assume like this: The event occurs, then Right disappears, and Right1 will disappear then reappear after 1 second. Then Right2 will disappear and reappear after 1 second, etc. Right will reappear after everything else.

If this is the case, you simply have things out of order. Your wait(1) should be between setting the transparency to 0/1, instead of between objects. Also, you should set transparency to 1 (invisible) first, then set back to 0. Doing it the way you have it (other way around) will make them visible first, then invisible after, resulting in every part except Right to be invisible in the end.

The correct script would look like this:

function onClick(player)
    -- Make 'Right' invisible
	player.Character.Right.Transparency = 1
	
	-- Make 'Right1' invisible for 1 second, then reappear
	player.Character.Right1.Transparency = 1
	wait(1)
	player.Character.Right1.Transparency = 0
	
	-- Make 'Right2' invisible for 1 second, then reappear
	player.Character.Right2.Transparency = 1
	wait(1)
	player.Character.Right2.Transparency = 0

	-- Make 'Right3' invisible for 1 second, then reappear
	player.Character.Right3.Transparency = 1
	wait(1)
	player.Character.Right3.Transparency = 0
	
	-- Make 'Right4' invisible for 1 second, then reappear
	player.Character.Right4.Transparency = 1
	wait(1)
	player.Character.Right4.Transparency = 0
	
	-- Make 'Right' reappear
	player.Character.Right.Transparency = 0  
end

script.Parent.ClickDetector.MouseClick:Connect(onClick)

Hope this helps! :)

This discussion is preserved as it was. New answers, comments, and votes are closed.