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

Prompting Developer Product Problems. ??????

Asked by 5 years ago

Local Script (Ignore the part at the top):

local player = game:GetService("Players").LocalPlayer
local PlayerGui = player.PlayerGui

while true do
    Money = player:WaitForChild("leaderstats").Money.Value
    PlayerGui.ScreenGui.MoneyLabel.Text = "Money: " .. Money
    Gems = player:WaitForChild("leaderstats").Gems.Value
    PlayerGui.ScreenGui.GemsLabel.Text = "Gems: " .. Gems
    wait(.1)
end


function onClicked()
game.ReplicatedStorage.RemoteEvent:FireServer(player)
end

script.Parent.ShopButton.Activated:Connect(onClicked)

Normal Script (Ignore the part at the top):

local function onPlayerJoin(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local Money = Instance.new("IntValue")
    Money.Name = "Money"
    Money.Value = 0
    Money.Parent = leaderstats


    local Gems = Instance.new("IntValue")
    Gems.Name = "Gems"
    Gems.Value = 0
    Gems.Parent = leaderstats
end

game.Players.PlayerAdded:Connect(onPlayerJoin)


local MarketplaceService = game:GetService("MarketplaceService")
local productID = 453120071

function OnServerEvent(plr)
    MarketplaceService:PromptProductPurchase(plr, productID)
end

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(OnServerEvent)
0
Does not prompt. PaliKai13 92 — 5y
0
maybe edit your last question instead of making a new question theking48989987 2147 — 5y
0
Instead of having a while loop to change the display, use a changed event. User#25115 0 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

The onClicked function you made will never be registered because the while true do loop you made prevents the code from reaching it. You can move the onClicked function AND the script.Parent.ShopButton.Activated:Connect(onClicked) before the loop so that it will register.

Ad

Answer this question