Hi guys. this script is meant to buy some items for the player. I clicked on the gui, and I saw "Clicked" in the output (as expected). What is confusing me is why it is not buying it even though all the requirements are fulfilled (FPoints value is 5 or more, "Cardboard" boolean is set to false which means that the boolean is also present). No output errors or warnings occurred. The output did not print "checked", therefore it also will not print "saved". Here's the script:
The location of this script is in StarterGui (game.StarterGui.Script or game.Players.PlayerName.PlayerGui.Script)
player = script.Parent.Parent function Check(Price) ls = player.leaderstats.FPoints if ls.Value >= Price then return true end end function Buy(Price) ls.Value = ls.Value-Price end if not player:FindFirstChild("Cardboard") then Cardboard = Instance.new("BoolValue",player) Cardboard.Name = "Cardboard" Cardboard.Value = false end gui = game.Workspace.Lobby.shopwall.SurfaceGui.Frame gui.Cardboard.MouseButton1Click:connect(function() print("Clicked") if Cardboard ~= nil and Cardboard.Value == false and Check(5) then print("checked") Cardboard.Value = true Buy(5) print("Bought") DSS:SetAsync("Cardboard",true) print("Saved") end end)