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

How do i make when the player has amout of money then they can press the button?

Hello i been trying to make a game and i need an upgrade button. and i dont know how to make when a player has a cercent amount of money they can press and upgrade. here is my code

-- Variables --
local Button = script.Parent

-- Mechanics --
Button.MouseButton1Click:Connect(function()
	if
		game.Players.LocalPlayer.leaderstats.Clicks.Value = 10
		then
	Button.Parent.Click.GiveCoins1k:Destroy()
	wait(0.1)
	Button.Parent.Click.GiveCoins2k.Disabled = false
	wait(0.1)
	Button.Parent.Cost.Text = "Cost 2000"
	script:Destroy()
end)

2 comments

0

Is this a localscript or ServerScript?

0

Use remoteEvents

2 answers

Best way to do this is in a server side script so dont use local

Alright so first you can get player from finding leaderstats

start off like this

-Ok So first you gotta count how many parents you need to get to game from the script in startergui

local lead = script.Parent.Parent.Parent.Parent:WaitForChild("leaderstats")
--Now we can get player 
local player = lead.Parent
local leaderstats = player:WaitForChild("leaderstats")
--so now we can start by localizing  clicks 
local clicks = leaderstats:WaitForChild("Clicks")
script.Parent.MouseButton1Click:Connect(function()--Function OnClicked
--We cab start by making a if statement if they have the right amount of clicks or higher
if clicks.Value >= 10 then --If they got enough clicks or more then this happens
--KK now you do what happens when they have the right amount
script.Parent.Parent.Click.GiveCoins1k:Destroy() --Destroys coins1k
wait(.1)--Wait Statement 
script.Parent.Parent.Click.GiveCoins2k.Disabled = false --Makes GiveCoins2k enabled
wait(.1)--Wait Statement 
script.Parent.Parent.Cost.Text = "Cost 2000" --Makes the text of cost "Cost 2000"
wait(.1)--Wait Statement 
script.Parent:Destroy()--Destroys script like what you put in your script but you forgot parent
	end
end)--ends function


Also for local `lead = script.Parent`` you need to adjust how many parents until you get the game

alright so I explained a lot next to the script and this is how you would do this locally but 1 thing would be taking the 10 clicks away when they click which you can do clicks.Value -= 10 after the then hope this helps accept if so

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