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
wait(0.1)
currentbutton = currentbutton + 1
wait(0.1)
local newbut = ButtonFolder:FindFirstChild("Button_"..numb)
button.Light.BrickColor = BrickColor.new("Lime green")
spawn(check(currentbutton, Map))
game.ReplicatedStorage.Bindables.InteractiveFunction:Invoke(currentbutton)
end
game.ReplicatedStorage.Bindables.ButtonFunction.OnInvoke = function(totalbuttons, Number, Map, ButtonFolder)
ButtonFolder:FindFirstChild("Button_"..currentbutton).Hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if Map.StartButton.Value == false then
Map.StartButton.Value = true
spawn(firstbuttontouched(Map, ButtonFolder))
end
end
end)
end
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"
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.
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.