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

Player has a boolvalue that is true but why does this GUI not appear?

Asked by
Vxpper 101
4 years ago

I'm working on an Inventory system, I have run into a problem that basically doesn't make a GUI appear if the player has a BoolValue thats value is true.

Here is the code:

--<< Variables >>--
local plr = game.Players.LocalPlayer
local bool = plr.ShopItems.Knives

--<< Frames >>--
local bg = script.Parent
local knifeinv = bg.Knives
local revinv = bg.Revolver
local abilinv = bg.Abilities
local petinv = bg.Pets
local radioinv = bg.Radios
local newknife = knifeinv.Template:Clone()

if bool.Common.Value == true then
    newknife.Visible = true
    newknife.Name = "KnifeA"
    newknife.Rarity.ImageColor3:FromRGB(43,125,43)
    newknife.Text = "Starter"
else
    return false
end

if bool.UnCommon.Value == true then
    newknife.Visible = true
    newknife.Name = "KnifeB"
    newknife.Rarity.ImageColor3:FromRGB(43,125,43)
    newknife.Text = "Skies"
else
    return false
end

If you can help, please do and thank you for taking the time to read this

0
`returns` in loops outside of a function's (or module's) scope mean nothing and are therefore useless dualworlds 90 — 4y
0
Is that my problem? Or is there more to it? Vxpper 101 — 4y

1 answer

Log in to vote
0
Answered by
royaltoe 5144 Moderation Voter Community Moderator
4 years ago

Since the code isn't inside an event or a loop, the if statements only run when the script is created. You can use the following event to see when it's value changed:


boolValue = bool.Common boolValue.Changed:Connect(function() print(boolValue.Value) end)
0
Using this i Changed my code Vxpper 101 — 4y
0
And it still does not appear. This is a local script,I probably should have said that Vxpper 101 — 4y
0
If you click the boolvalue in the properties thats not going to fire the function. you have to change it in a script for the game to recognize it royaltoe 5144 — 4y
0
click the bool values value to make it true it's not going to work* royaltoe 5144 — 4y
View all comments (3 more)
0
I have a crate system that changes the value through a script in ServerScriptService Vxpper 101 — 4y
0
try changing it right after the event is made on line 6 and see if that works royaltoe 5144 — 4y
0
if that works its the logic with the create so youll need to go through that royaltoe 5144 — 4y
Ad

Answer this question