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)
If you're getting no errors, this means you're running a script on the wrong side of the game. You could be on client or server.
Read this article about remoteEvents: https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events
It might help.
If this doesn't work just send me a message on Roblox or Discord. (cheddarr#0001)
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