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

Boolean Value in StarterGUI isn't working correctly?

The if statement in my code will not work for some reason when I include this boolean value even though the value is true.

local part = workspace:WaitForChild("ActivateBurgerJob")
local plr = game.Players.LocalPlayer;
local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
local Controls = PlayerModule:GetControls()
local ui = script.Parent;
canSeeGui = script.Parent.Parent:WaitForChild("canSeeGui")

local function onTouch(hit)
	print(canSeeGui.Value)
	if plr.Character ~= nil and hit.Parent == plr.Character and canSeeGui == true then
		wait(0.2)
		canSeeGui = false
    	Controls:Disable()
		ui.Enabled = true
		print("Contrls disbaled")	   
	end 

end

Here's where the boolean value is located

3 comments

0

lol for some reason it wont let me post an answer. The problem is you forgot to get the .Value property of the BoolValue; you are checking to see if the value exists, not if it is true. Change line six to "canSeeGui = script.Parent.Parent:WaitForChild("canSeeGui").Value"

0

Ok so this seems to fix if statement and allow it to work, although line 12 does not change the value in the folder, is this because it is a local script?

0

It should change the value for the player who's starterGUI this is in. For all other players, the game will act like the value is still true.

1 answer

Try this

local part = workspace:WaitForChild("ActivateBurgerJob")
local plr = game.Players.LocalPlayer;
local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
local Controls = PlayerModule:GetControls()
local ui = script.Parent;
canSeeGui = script.Parent.Parent:WaitForChild("canSeeGui")

local function onTouch(hit)
    print(canSeeGui.Value)
    if plr.Character ~= nil and hit.Parent == plr.Character and canSeeGui.Value == true then
        wait(0.2)
        canSeeGui.Value = false
        Controls:Disable()
        ui.Enabled = true
        print("Contrls disbaled")      
    end 

end

3 comments

0

Players.FizzyFlame.PlayerGui.Jobs.BurgerJob.Gui.acceptJobGui.AcceptJob:9: attempt to index boolean with 'Value'

0

Thats the error I get when I try to do this

0

Are the lines here same as the post?

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