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

The script I am using to click blocks is not working, any help??

To be honest, I have no idea what I did wrong, or if I am missing something. In this script I want to click a block, and make another block have effects. Any help?


script.Parent.ClickDetector.MouseClick:Connect(function()
	
    game.Workspace.WoodlogWB.WoodP.Transparency = 0.9   
    wait(0.1)
    game.Workspace.WoodlogWB.WoodP.Transparency = 0.8  
    wait(0.1)
    game.Workspace.WoodlogWB.WoodP.Transparency = 0.7
    wait(0.1)
    game.Workspace.WoodlogWB.WoodP.Transparency = 0.6
    wait(0.1)
    game.Workspace.WoodlogWB.WoodP.Transparency = 0.5
    wait(0.1)
    game.Workspace.WoodlogWB.WoodP.Transparency = 0.4  
    wait(0.1)
    game.Workspace.WoodlogWB.WoodP.Transparency = 0.3
    wait(0.1)
    game.Workspace.WoodlogWB.WoodP.Transparency = 0.2
    wait(0.1)
    game.Workspace.WoodlogWB.WoodP.Transparency = 0.1
    wait(0.1)
    game.Workspace.WoodlogWB.WoodP.Transparency = 0
    wait(0.1)
    game.Workspace.WoodlogWB.WoodP.CanCollide = true

end)


   --WoologWB, and WoodP are the parts in game.
   --WoodP is the block I want to appear after clicking WoodlogWB. 
   --WoodLogWB has the the ClickDetector inside of it.

3 comments

0

USE A FOR LOOP !!!!!!

0

lol

0

No clue how to do that.

1 answer

✓ Accepted answer

You should use a for loop in this case as it's more efficient. You can find an explanation for these here: https://developer.roblox.com/articles/Roblox-Coding-Basics-Loops#For

This code should do the trick and you can let me know if you have any issues!

script.Parent.ClickDetector.MouseClick:Connect(function()
	for i = 0, 1, .1 do
		game.Workspace.WoodlogWB.WoodP.Transparency = 1 - i  
		wait(0.1)
	end

	game.Workspace.WoodlogWB.WoodP.CanCollide = true
end)

7 comments

0

The block won't appear?

0

There may be an error in the console/output, try looking there.

0

How do I fix this error? --"WoodP is not a valid member of Part"

0

It means it can't find WoodP in the Part.

0

What do I do about it?

0

Make a part called WoodP, if it's there try making sure it's anchored and/or cancollide.

0

Thank you, that worked.

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