Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CreateDict(Table)
- local PlayerF = {}
- for i,v in next, Table do
- PlayerF[v.Name] = v.Value
- end
- return PlayerF
- end
- function Count(Table)
- local Count = 0;
- for i,v in next, Table do
- Count = Count+1
- end
- return Count;
- end
- function Check(PFolder,Requirments)
- local Count = 0;
- for i,v in next, Requirments do
- if tonumber(PFolder[i]) ~= nil and PFolder[i] and PFolder[i] >= v then
- Count = Count+1;
- end
- if tostring(PFolder[i]) ~= nil and PFolder[i] and PFolder[i] == v then
- Count = Count+1;
- end
- end
- return Count;
- end
- --[[Button must be the button instance not the click detector,
- Requirements must be the dictionary of Requirements
- Stat is the Stat to be indexed if they meet the requirement
- Value is what the stats value should be set to if they meet the requirement
- --]]
- function CreateClick(Button,Requirements,Stat,Value)
- local Original = Button.Name;
- Button.Head.ClickDetector.MouseClick:connect(function(PLAYER)
- local PFolder = game:GetService("ServerStorage").PlayerFolders:WaitForChild(tostring(PLAYER))
- local PFolderDict = CreateDict(game:GetService("ServerStorage").PlayerFolders:WaitForChild(tostring(PLAYER)):GetChildren())
- if Count(Requirements) ~= Check(PFolderDict,Requirements) then
- Button.Name = "Improper requirements";
- wait(2)
- Button.Name = Original;
- elseif Count(Requirements) == Check(PFolderDict,Requirements) then
- if Requirements["Gold"] then
- PFolder.Gold.Value = PFolder.Gold.Value - Requirements["Gold"];
- end
- PFolder[Stat].Value = Value;
- Button.Name = "Success!"
- wait(2)
- Button.Name = Original;
- end
- end)
- end
- local CyborgReq3 = {["LVL"] = 15, ["Gold"] = 40000,["Race"] = "Cyborg",["CyborgUpgrade2"] = true}
- CreateClick(workspace["Cyborg Upgrade3 [40k Beli] [Level 15]"],CyborgReq3,"CyborgUpgrade3",true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement