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

[STILL UNANSERWED] Buying in game currency script help?

Asked by 10 years ago
local productId = 20983086 
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function() 
    Game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
end)




if plr and plr:FindFirstChild"leaderstats" and plr.leaderstats:FindFirstChild"Credits" then
plr.leaderstats.Credits.Value = plr.leaderstats.Credits.Value + script.Parent.Name 
end

Hey, so i have this code, were the player buy '50 credits' which i have as a developer product it opens up okay but when bought, it doesn't give the player the sed amount they bought and i don't know how to change the script to make it happen.

I don't know if you'll need it but this is the leader board, which is also working properly

function onPlayerEntered(newPlayer) 

    local stats = Instance.new("IntValue") 
    stats.Name = "leaderstats"

    local robux = Instance.new("IntValue") 
    robux.Name = "Credits"
    robux.Value = 0                         
    robux.Parent = stats 
        stats.Parent = newPlayer 
end 
game.Players.ChildAdded:connect(onPlayerEntered) 

2 answers

Log in to vote
0
Answered by
faruque 30
10 years ago

I don't know if this might help but here.

if plr and plr:FindFirstChild("leaderstats")--Put Brackets between the text
plr.leaderstats:FindFirstChild("Credits") then
plr.leaderstats.Credits.Value = plr.leaderstats.Credits.Value + script.Parent.Name
end
0
Nope, on line 2 it gets the red error line and the buy window dosent open. aganetbatman 0 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

what you can also do is that after they purchase the "50 credits" pass for robux, make them able to go in the vip room that has a botton that u step on for 50 credits, but then it teleports u back and u cant take another one. making a vip only room is very easy and can be found in free models

Answer this question