Hello! And I was scripting but I found an error inside my script. Feel free to ask many questions!
local function firstbuttontouched(Map, ButtonFolder, numb)
local button = ButtonFolder:FindFirstChild("Button_1")
button.Light.BrickColor = BrickColor.new("Really red")
button.Light.Touched.Value = true
currentbutton = currentbutton + 1
local newbut = ButtonFolder:FindFirstChild("Button_"..numb)
button.Light.BrickColor = BrickColor.new("Lime green")
game.ReplicatedStorage.Bindables.ButtonFunction.OnInvoke = function(totalbuttons, Number, Map, ButtonFolder)
if hit.Parent:FindFirstChild("Humanoid") then
if Map.StartButton.Value == false then
Map.StartButton.Value = true
The error said,
"Value cannot be assigned to
16:31:17.721 - Stack Begin
16:31:17.723 - Script 'ServerScriptService.Buttons', Line 37 - upvalue firstbuttontouched
16:31:17.724 - Script 'ServerScriptService.Buttons', Line 61
16:31:17.725 - Stack End"
When you use spawn, you’ll want to create an anonymous function:
There was also a mention awhile back where it was suggested to use
coroutine instead of spawn, because spawn has a built-in wait() before executing anything. It most likely has little effect in this situation.
Also a heads up, in your bottom function call to firstbuttontouched, you provide no third argument. So numb will always be null in that call. I also suggest you Camel-case your function names.
I didn’t add ‘.Value’ in line 37 and 38.
So if I use the spawn(function() I can put more arguments in? And how do you use coroutine?
The no-named function() created within the spawn() function is called an “anonymous function”. To my knowledge you must create that anon function in your case, due to some internal reasons with spawn() (it itself has some default arguments that Roblox uses behind the scenes). So simply wrap your function call inside an anonymous function and do whatever you want with it.
Where would I put coroutine inside my script? Like how do I call the function?