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)
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.