Code:
local button = CreateFrame("Button", nil, UIParent, "UIPanelButtonTemplate")
button:SetSize(100,20)
button:SetPoint("CENTER")
button:RegisterForClicks("AnyUp")
button:SetText("Start")
button:SetScript("OnClick", function(self,btn)
if self:GetText()=="Start" then
self:SetText("Stop")
else
self:SetText("Start")
end
end)
button:SetMovable(true)
button:RegisterForDrag("LeftButton")
button:SetScript("OnDragStart", button.StartMoving)
button:SetScript("OnDragStop", button.StopMovingOrSizing)
button:SetScript("OnHide", button.StopMovingOrSizing)
button:Show()
This should make a minimal button for testing but your error mentions line 641, meaning there's a ton of code you're not showing.
The most probable cause is that fs does not exist inside StopStart because it is defined as a local in another scope.