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

What's wrong with this function?

Asked by
Restic 15
10 years ago
function ChangeBase(brick)
    brick.Transparency = 0.5
end 

ChangeBase(Base)

-I don't have a part named 'brick' inside workspace, but I have a brick named 'Base' inside workspace

OUTPUT: Workspace.Script:2: attempt to index local 'brick' (a nil value) 13:03:11.924 - Script 'Workspace.Script', Line 2 - global ChangeBase 13:03:11.924 - Script 'Workspace.Script', Line 5 13:03:11.925 - stack end

1 answer

Log in to vote
2
Answered by
User#2 0
10 years ago

Your problem is you're trying to use Base but roblox doesn't know what it is. How would they know?

You need to work with objects roblox does know, and work your way towards Base.

Luckily, Workspaceis predefined in all scripts! To fix your error, just put Workspace.Basewhere Base is!

ChangeBase(Workspace.Base)
0
Thanks, it worked Restic 15 — 10y
Ad

Answer this question