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

[STILL UNANSERWED] Buying in game currency script help?

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

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

1 comment

0

Nope, on line 2 it gets the red error line and the buy window dosent open.

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

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