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

Why is this function not registering? Nothing is coming out in Output either.. (2nd function)

function changeTrans(brick, trans)
	workspace:FindFirstChild(brick).Transparency = trans
end

changeTrans("Yellow", 0.5)
changeTrans("Blue", 0.9)
changeTrans("Red", 0.2)
changeTrans("Green", 0.99)
changeTrans("Bronze", 0.34)

function changeProp(brick, collide)
	workspace:FindFirstChild(brick).CanCollide = collide
end

changeProp("Yellow", false)
changeProp("Blue", false)
changeProp("Red", true)
changeProp("Green", false)
changeProp("Bronze", false)

2 comments

1

I would add "wait()" between each one and like " print("WhateverColors cancollide is false") " after each calling of the function to see where it is stopping.

1

Add a print to the top of the code if this does not print then the code is not being ran, i do not see a problem with the code except you do not handle an occurance of nil.

1 answer

✓ Accepted answer

You need a condition to activate the function For example a GUI button

local button = game.StarterGUI.ScreenGUI.Button

button.MouseButton1Down:connect(
function()
	--The code stuff
end)

Or another way to activate the function if you have two of them:

local button1 = game.StarterGUI.ScreenGUI.Button1
local button2 = game.StarterGUI.ScreenGUI.Button2

function a()
	--CodeA
end

function b()
	--CodeB
end

button1MouseButton1Down:connect(a)
button2MouseButton1Down:connect(b)

So basically, it's condition:connect(functionname)

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