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

Purchase wont work on my Shop Gui when the script confirms purchase. Why?

So i wanna make a normal shop script, it worked when i set the points to the price the exact price, but not when i waited until the points got up to the price you had to pay.

Here's my code: (In a LocalScript)

local money = game.StarterGui.CoreGui.ShopMenu.PlayerPoints.num

script.Parent.MouseButton1Click:Connect(function()
	if tonumber(money.Text) >= 1500 then	
		workspace.PlanetPlacement.BillboardGui.Enabled = true
		workspace.PlanetPlacement2.BillboardGui.Enabled = true
		workspace.PlanetPlacement3.BillboardGui.Enabled = true
		workspace.Planet.PlanetBall.BillboardGui.Enabled = true
		money.Text = money.Text - 1500
		print("Purchase Complete!")
	end
end)

That's what i wrote. And when i set the points to 1500 manually, it worked; but when i waited until it got to 1500 points, i clicked a button which would run the script inside the function (at least that's what i thought) [Also the points went up +35 points every second in a while true do loop, i didn't set it to +1 point every second xD] and when i tried to do another if then statement when the player didn't have enough points, i used <= and when i tried it when the points were less than 1500, it said "Purchase Failed", like i wanted it to. And when i had +1500 points, it still said "Purchase Failed" And the same thing when i had enough points. What should i do??

Thx for ur help that you hopefully give me! LOL

~Chez_Guy

1 answer

never ever use StarterGui in a script, reference PlayerGui by using the localscript

local money = script.Parent.Parent.PlayerPoints.num -- this is an example, change it to the location of the playerpoints

script.Parent.MouseButton1Click:Connect(function()
    local MONEY = tonumber(money.Text)
    if  >= 1500 then    
        workspace.PlanetPlacement.BillboardGui.Enabled = true
        workspace.PlanetPlacement2.BillboardGui.Enabled = true
        workspace.PlanetPlacement3.BillboardGui.Enabled = true
        workspace.Planet.PlanetBall.BillboardGui.Enabled = true
        money.Text = tostring(tonumber(money.Text) - 1500)
        print("Purchase Complete!")
    end
end)

this won't work with FE btw

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