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

GUI button doesn't change StringValue to 'Open' Why?

Asked by 2 years ago
Edited 2 years ago

basically I have a confirm message that says yes or no. i want it so when you click Yes, it turns OpenValue to Open (essentially opening the egg). i thought this script would work but apparently not.. Am i missing something? here's the code:

local RS = game:GetService("ReplicatedStorage")
local Eggs = require(RS:WaitForChild("Eggs"))
local Data = Eggs[script.Name]
local Cost = Data["Cost"]
local Pets = Data["Pets"]


local Buy = game.StarterGui.Message.Frame
local CD = Buy.Yes
local CostGUI = Buy
local CostText = CostGUI:WaitForChild("Cost")

CostText.Text = Cost.." Coins?"

local TotalWeight = 0
for i,v in pairs(Pets) do
    TotalWeight = TotalWeight + v[1]
end

local function ChoosePet()
    local Chance = math.random(1,TotalWeight)
    local Counter = 0
    for i,v in pairs(Pets) do
        Counter = Counter+v[1]
        if Chance <= Counter then
            return i
        end
    end
end

CD.MouseButton1Click:Connect(function(Player)
    local Stats = Player:WaitForChild("leaderstats")
    local Coins = Stats:WaitForChild("Coins")
    local open = Player:WaitForChild('OpenValue')
    local got = Player:WaitForChild('GotPet')
    if Coins.Value >= Cost then
        Coins.Value = Coins.Value - Cost
    open.Value = 'Open'
    got.Value = ChoosePet()
    local findpet = Player:WaitForChild('Pets')
    local sqq = findpet:FindFirstChild(got.Value)
     sqq.Value = 'owned'
        wait(5)
    open.Value = 'Close'
    got.Value = ''
    end
end)

0
The thing is, you're using a BoolValue. BoolValue's can be set only to 'true' or 'false'. Anything else will not work. If you are actually secretly using a StringValue, then I have no idea. XRed03 17 — 2y
0
yeah my bad its a string value User#31501 0 — 2y

Answer this question