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

So I am a beginner at scripting? Help please

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

Im trying to change the material of a brick... This is my script that I made but does not work.

while true do
game.Workspace.Part.Material = (Wood)
wait(1)
game.Workspace.Part.Material = (Foil)
wait(1)

2 answers

Log in to vote
2
Answered by 8 years ago

A string is needed, otherwise, Wood and Foil are not defined, so they would be read as nil, you were also missing an end.

Here's the script:

while true do 
    workspace.Part.Material = "Wood"
    wait(1)
    workspace.Part.Material =  "Foil"
    wait(1)
end

Consider reading about strings this will help you understand what strings are and how to use them.

Hope it helps!

0
I did mistake the script. I forgot an end and I forgot that it was quotations. But I don't get how u don't say game.Workspace FiredDusk 1466 — 8y
0
You don't need game.Workspace, that's just typing 5 pointless characters, and this method only works for workspace. AbsoluteAxiom 175 — 8y
0
game.Workspace is the full path, and you do need the 'game' if you want to access other services, like ServerStorage. However, since workspace is used so often, Roblox has a built in variable for it. It's like saying 'workspace = game.Workspace' at the top of your script, only roblox does it for you. Perci1 4988 — 8y
Ad
Log in to vote
2
Answered by
funyun 958 Moderation Voter
8 years ago

First of all, loops create scopes. In the output, whenever you see 'end' expected...blah blah... near <eof>, it means you need to put "end" at the end of a scope.

Second, get rid of the parenthesis. Use quotation marks to change properties that want strings. Strings in programming are basically just words, or text in general.

while true do
    workspace.Part.Material = "Wood" --Protip: You can use "workspace" instead of "game.Workspace" to refer to the workspace. That only works for workspace.
    wait(1)
    workspace.Part.Material = "Foil"
    wait(1)
end

More about scopes: http://wiki.roblox.com/index.php?title=Scope

1
Ugh you beat me to it! Upvoted! AbsoluteAxiom 175 — 8y

Answer this question