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

Data Store Question/Problem????

Asked by 10 years ago

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)
0
~~~~~~~~~~~~~~~~ I used that to identify the line... micke3212 35 — 10y

3 answers

Log in to vote
0
Answered by 10 years ago
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

0
Just stated 5 minutes ago ~~~~~~~~~~~~~~~~ to identify the problem to make it easier to see. micke3212 35 — 10y
0
-.- Look, tell us where is aree variable defined at. marcoantoniosantos3 200 — 10y
0
aree is os.time micke3212 35 — 10y
0
tell us the line... marcoantoniosantos3 200 — 10y
View all comments (8 more)
0
Updated question micke3212 35 — 10y
0
send us full script, so we know where os comes from marcoantoniosantos3 200 — 10y
1
okay, let me see if i can fix it marcoantoniosantos3 200 — 10y
0
Ok, it's a TextButton f is a frame. micke3212 35 — 10y
0
ohhh, this is a Gui. Okay marcoantoniosantos3 200 — 10y
0
Try now, it should work, if it doesn't, tell me the whole output line marcoantoniosantos3 200 — 10y
0
Try the newest version. it should work marcoantoniosantos3 200 — 10y
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. adark 5487 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

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
Hows it looking? micke3212 35 — 10y
Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

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.

Answer this question