so it errors with this... Players.Deinonychusaurus.PlayerGui.BreadGui.TextButton.LocalScript:17: Expected 'end' (to close 'else' at line 11), got <eof> code :
local player = game:GetService("Players").LocalPlayer local button = script.Parent local Digfunction = player.Backpack.DigFunction local xd = true button.Activated:Connect(function() if xd == true then Digfunction.Disabled = true xd = false else if xd == false then Digfunction.Disabled = false xd = true end
At line 10, you set XD to false. And at line 12, you wanted to set XD to true if XD was false. The problem is that line 12 is after line 10. So it will always set XD to true. We have to find a way to return to the beginning of the function to not run the lines 12 to 14 just after setting XD to false. We can us the function return to return to the beginning of the function:
local xd = false Button.Activated:Connect(function() if xd == false then xd = true DigFunction.Disabled = true return end if xd == true then xd = false DigFunction.Disabled = false -- we don't need to return, cuz it's the end of the function. end end)
Also, idk why you added a else at line 11. If you wanted to use the else function, delete line 12.
Hope this helped!
Sorry I didn't have time to write all the variables cuz I'm on mobile. Sorry.
I think this is what you wanted
local player = game:GetService("Players").LocalPlayer local button = script.Parent local Digfunction = player.Backpack.DigFunction local xd = true button.Activated:Connect(function() if xd == true then Digfunction.Disabled = true xd = false elseif xd == false then -- this was a bad boy Digfunction.Disabled = false xd = true end end