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)
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)
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!
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
Ugh you beat me to it! Upvoted!
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
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
You don't need game.Workspace, that's just typing 5 pointless characters, and this method only works for workspace.
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.