Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

2 comments

0

returns in loops outside of a function's (or module's) scope mean nothing and are therefore useless

0

Is that my problem? Or is there more to it?

1 answer

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)

7 comments

0

Using this i Changed my code

0

And it still does not appear. This is a local script,I probably should have said that

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

0

click the bool values value to make it true it's not going to work*

0

I have a crate system that changes the value through a script in ServerScriptService

0

try changing it right after the event is made on line 6 and see if that works

0

if that works its the logic with the create so youll need to go through that

This discussion is preserved as it was. New answers, comments, and votes are closed.