Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Data Store Question/Problem????

Line 5 issue

local id1 = 19453079
local id2 = 20607058
plr = script.Parent.Parent.Parent
local aree = os.time
script.Parent.f.b.MouseButton1Click:connect(function()
g = game:GetService("MarketplaceService")
g:PromptProductPurchase(plr, id1)
end)

script.Parent.f.ar.MouseButton1Click:connect(function()
DataStore = game:GetService("DataStoreService"):GetGlobalDataStore(shoplistaer)
local a=DataStore:GetAsync("user_"..plr.userId)
if a then
if a >= aree then
for i, v in pairs(game.Workspace:GetChildren()) do if v:IsA("Sound") then v:Destroy() end end
local pitch = 1
local id = script.Parent.f.ss
local s = Instance.new("Sound", game.Workspace) s.SoundId = "http://www.roblox.com/asset/?id=" .. id.Value s.Volume = 1 s.Pitch = pitch s.Looped = true s.archivable = false repeat s:Play() wait(2.5) s:Stop() wait(.5) s:Play() until s.IsPlaying
elseif a <= aree then
g = game:GetService("MarketplaceService")
g:PromptProductPurchase(plr, id2)
end
else
DataStore:SetAsync("user_"..plr.userId, 0)
g = game:GetService("MarketplaceService")
g:PromptProductPurchase(plr, id2)
end
end)

1 comment

0

3 answers

local id1 = 19453079 -- yep. mistake people always do...
local id2 = 20607058 -- once again, the mistake happens!
-- well, let me fix this two.
plr = script.Parent.Parent.Parent
local aree = os.time
script.Parent.f.b.MouseButton1Click:connect(function()
g = game:GetService("MarketplaceService")
g:PromptProductPurchase(plr, idone)
end)

script.Parent.f.ar.MouseButton1Click:connect(function()
DataStore = game:GetService("DataStoreService"):GetGlobalDataStore(shoplistaer)
local a=DataStore:GetAsync("user_"..plr.userId)
if a then
if a >= aree then
for i, v in pairs(game.Workspace:GetChildren()) do if v:IsA("Sound") then v:Destroy() end end
local pitch = 1
local id = script.Parent.f.ss
local s = Instance.new("Sound", game.Workspace) s.SoundId = "http://www.roblox.com/asset/?id=" .. id.Value s.Volume = 1 s.Pitch = pitch s.Looped = true s.archivable = false repeat s:Play() wait(2.5) s:Stop() wait(.5) s:Play() until s.IsPlaying
elseif a <= aree then
g = game:GetService("MarketplaceService")
g:PromptProductPurchase(plr, id2)
end
else
DataStore:SetAsync("user_"..plr.userId, 0)
g = game:GetService("MarketplaceService")
g:PromptProductPurchase(plr, id2)
end
end)

This is the fixed version i've made:

local idone = 19453079
local idtwo = 20607058
plr = script.Parent.Parent.Parent
local aree = os.time()
function itWasClickedOMG()
g = game:GetService("MarketplaceService")
g:PromptProductPurchase(plr, idone)
end

script.Parent.f.ar.MouseButton1Click:connect(function()
DataStore = game:GetService("DataStoreService"):GetGlobalDataStore(shoplistaer)
local a=DataStore:GetAsync("user_"..plr.userId)
if a then
if tonumber(a.keyvalue) >= tonumber(aree) then
for i, v in pairs(game.Workspace:GetChildren()) do if v:IsA("Sound") then v:Destroy() end end
local pitch = 1
local id = script.Parent.f.ss
local s = Instance.new("Sound", game.Workspace) s.SoundId = "http://www.roblox.com/asset/?id=" .. id.Value s.Volume = 1 s.Pitch = pitch s.Looped = true s.archivable = false repeat s:Play() wait(2.5) s:Stop() wait(.5) s:Play() until s.IsPlaying
elseif a <= aree then
g = game:GetService("MarketplaceService")
g:PromptProductPurchase(plr, idtwo)
end
else
DataStore:SetAsync("user_"..plr.userId, 0)
g = game:GetService("MarketplaceService")
g:PromptProductPurchase(plr, idtwo)
end
end)

script.Parent.f.b.MouseButton1Click:connect(itWasClickedOMG)

Hope this helped! Thanks, marcoantoniosantos3

12 comments

0

Just stated 5 minutes ago ~~~~~~~~~~~~~~~~ to identify the problem to make it easier to see.

0

-.- Look, tell us where is aree variable defined at.

0

aree is os.time

0

tell us the line...

0

Updated question

0

send us full script, so we know where os comes from

1

okay, let me see if i can fix it

0

Ok, it's a TextButton f is a frame.

0

ohhh, this is a Gui. Okay

0

Try now, it should work, if it doesn't, tell me the whole output line

0

Try the newest version. it should work

0

By the way, marco, os is defined by the Lua library the ROBLOX engine uses. It is automatically defined in every script, although we in ROBLOX can only use one of its members, the time method.

Output: Attempt to compare function with number :17

local idone = 19453079
local idtwo = 20607058
plr = script.Parent.Parent.Parent
local aree = os.time


function one()
g = game:GetService("MarketplaceService")
g:PromptProductPurchase(plr, idone)
end
script.Parent.f.b.MouseButton1Click:connect(one)

function two()
DataStore = game:GetService("DataStoreService"):GetGlobalDataStore(shoplistaer)
local a=DataStore:GetAsync("user_"..plr.userId)
if a then
if a >= aree then
for i, v in pairs(game.Workspace:GetChildren()) do if v:IsA("Sound") then v:Destroy() end end
local pitch = 1
local id = script.Parent.f.ss
local s = Instance.new("Sound", game.Workspace) s.SoundId = "http://www.roblox.com/asset/?id=" .. id.Value s.Volume = 1 s.Pitch = pitch s.Looped = true s.archivable = false repeat s:Play() wait(2.5) s:Stop() wait(.5) s:Play() until s.IsPlaying
elseif a <= aree then
g = game:GetService("MarketplaceService")
g:PromptProductPurchase(plr, idtwo)
end
else
DataStore:SetAsync("user_"..plr.userId, 0)
g = game:GetService("MarketplaceService")
g:PromptProductPurchase(plr, idtwo)
end
end

script.Parent.f.ar.MouseButton1Click:connect(two)

1 comment

1

Hows it looking?

I don't know why the other two answers changed it, but there is absolutely nothing wrong with naming a variable id1 or id2. As long as either an underscore ( '_' ) or english letter starts the variable name, numbers can be freely used.

You problem is that os.time needs to be os.time(), as you are trying to invoke the time method, not access the function itself.

This discussion is preserved as it was. New answers, comments, and votes are closed.