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

Why isn't this TextLabel not changing when it's supposed to?

Asked by 5 years ago

here's the script: https://pastebin.com/raw/ruZc7WA9 The specific sections in the script i'm focusing on: if view.Value == 2 then if cookie2 and not unequippedcookie2 then script.Parent.TextLabel.Text = "Equipped" elseif not cookie2 and unequippedcookie2 then script.Parent.TextLabel.Text = "Equip" elseif not cookie2 and not unequippedcookie2 then script.Parent.TextLabel.Text = "Purchase" end and spawn(function() script.Parent.MouseButton1Click:Connect(function() if view.Value == 2 and not cookie2 and not unequippedcookie2 then print("hi") if plr.leaderstats.Money.Value >= 100 then plr.leaderstats.Money.Value = plr.leaderstats.Money.Value - 100 local cookie = game.ReplicatedStorage["Peanut Butter Cookie"]:Clone() cookie.Parent = plr.unequippedtools cookie.Name = "Peanut Butter Cookie" end end end) end) NOTE: THIS IS ALL IN THE SAME LOCAL SCRIPT INSIDE OF "game.Players.LocalPlayer.PlayerGui.shopgui.shop.back.button" the first section shown above is what i like to call the "check", it is constantly checking (due to the while wait do in the pastebin link given) view.Value to see which item in the shop the player is currently looking at. if you read the script in the pastebin link, you'll see what all of the "view.Value", "cookie2", "unequippedcookie2", etc are. the second section is the actual buy script that when the player clicks on the button, it'll charge the player and it will also clone a cookie and parent it to the localplayer's unequippedtools folder.

my issue: whenever I click on "Purchase" underneath the second cookie in the shop (aka view.Value == 2), the textlabel is supposed to change from "Purchase", to "Equip", so the player can choose to equip the cookie after they have bought it, but the textlabel doesn't change at all, it just stays as "Purchase", meaning the player can buy 999999 of those cookies if they had the money to. i'm not sure why its not working, as the check is constantly checking whether the player has bought the item and the cookie has been cloned to the local player's unequippedtools folder, bought the item and has it equipped (aka the cookie is in their backpack), or hasn't bought the item. I asked my friends, none of them knew the fix, I tried making a table containing all of the findfirstchilds and tried using the for i,v in pairs() do thing to pull the data from the table, didn't work, I tried using remote events/functions, didn't work, i don't know what the issue is but i'm sure you can all tell that the shop i'm working on is a heavyyyy feature that the game counts on to stay relevant and new, so if the shop isn't working, the game isn't as good as it should be.

If anyone can help, that'd be amazing. Thank you <3

0
Access it from the PlayerGui. DeceptiveCaster 3761 — 5y
0
You need to change the value outside of StarterGui or use a remote event User#25281 0 — 5y
0
Also use elseif instead of end and then if AswormeDorijan111 531 — 5y
0
None of those solutions work.. I made sure I’m accessing it from PlayerGui, tried changing the textlabel’s text outside of startergui (which broke the script), and if I try to use elseif instead of end and then if, it breaks the script as well. Anyway someone can come look at it? DM me on discord: Meeseek#9054 innocentbystander7 0 — 5y

Answer this question