Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is the script not working?

Asked by 10 years ago

I am making a player point loterry. Once someone buys the coins to put in the machine the prize should go up by one. But it doesnt. THis is the script. I also have a local script. Ill put that on in here after. NORMAL SCRIPT!

     ~~~~~~~~~~~~~~~~~

function GetPlayer(x) if x=="all"then return game.Players:GetPlayers() else for _,v in ipairs(game.Players:GetPlayers())do if v.Name:sub(1,#x):lower()==x:lower()then return{v} end end end return{} end

local coins={} local t={} game.Players.PlayerAdded:connect(function(player) local l=Instance.new("IntValue",player) l.Name="leaderstats" local c=Instance.new("IntValue",l) c.Name="Coins" coins[player.Name]=0 c.Value=0 if player.Name=="AmidaKami"then player.Chatted:connect(function(msg) local args={} for v in msg:gmatch("[^/]+")do args[#args+1]=v end if args[1]=="coins"and args[2]and args[3]then local players=GetPlayer(args[2]) for _,player in pairs(players)do coins[player.Name]=coins[player.Name]+(tonumber(args[3]or 0)or 0) player.leaderstats.Coins.Value=coins[player.Name] end elseif args[1]=="time"and args[2]and args[3]then if t[tonumber(args[2])or 1]then t[tonumber(args[2])or 1]=t[tonumber(args[2])or 1]+tonumber(args[3]or 0)or 0 end end end) end end)

workspace.ChildAdded:connect(function(x) if game.Players:GetPlayerFromCharacter(x)then script.Local:clone().Parent=x end end)

local P=game:GetService("PointsService") local boards=workspace.Boards:GetChildren() local pts=P:GetAwardablePoints() local points={} local win={} local current={} local gui={} local last={} for i=1,#boards do points[i]=pts/#boards t[i]=180 win[i]=6283170 current[i]="AmidaKami" gui[i]=boards[i].SurfaceGui last[i]="Nobody" end for i,v in ipairs(boards)do v.ClickDetector.MouseClick:connect(function(player) if coins[player.Name]>0 and current[i]~=player.Name then coins[player.Name]=coins[player.Name]-1 player.leaderstats.Coins.Value=coins[player.Name] if t[i]<120 then t[i]=t[i]+5 end win[i]=player.userId current[i]=player.Name gui[i].Win.Text="Currently winning: "..current[i] local m=math.floor(t[i]/60) local s=t[i]-m*60 gui[i].Time.Text=m.." Minute"..(m==1 and" "or"s ")..s.." Second"..(s==1 and ""or"s") end end) end

game:GetService("MarketplaceService").ProcessReceipt=function(receiptInfo) for _,player in ipairs(game.Players:GetChildren())do if player.userId==receiptInfo.PlayerId then if receiptInfo.ProductId==19737507 then for i=1,#boards do points[i]=points[i]+1/#boards if player.Name~="AmidaKami"then coins[player.Name]=coins[player.Name]+2 player.leaderstats.Coins.Value=coins[player.Name] if t[i]<120 then t[i]=t[i]+5 end end end return Enum.ProductPurchaseDecision.PurchaseGranted end end end end

while wait(1)do for i,v in ipairs(boards)do t[i]=t[i]-1 gui[i].Available.Text="Prize: "..math.floor(points[i]/2).." Player Points" local m=math.floor(t[i]/60) local s=t[i]-m*60 gui[i].Time.Text=m.." Minute"..(m==1 and" "or"s ")..s.." Second"..(s==1 and ""or"s") gui[i].Win.Text="Currently winning: "..current[i] if t[i]==0 then t[i]=180 last[i]=current[i] gui[i].Last.Text="Last winner: "..last[i] if math.floor(points[i])>0 then P:AwardPoints(win[i],math.floor(points[i]/2)) points[i]=points[i]-math.floor(points[i]/2) end end end end



LOCAL SCRIPT

wait() for _,v in ipairs(workspace.Boards:GetChildren())do v.SurfaceGui.Buy.MouseButton1Down:connect(function() if game.Players.LocalPlayer.leaderstats.Coins.Value<=8 then game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer,19737507) else local m=Instance.new("Message",game.Players.LocalPlayer.PlayerGui) m.Text="You can only buy coins if you have 8 or less left; they don't save." wait(3) m:Destroy() end end) end ~~~~~~~~~~~~~~~~~

Answer this question