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

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

Asked by 7 years ago
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)

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. RockerCaleb1234 282 — 7y
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. User#5423 17 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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)

Ad

Answer this question