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

How do I check if a bool value is checked or not? My code does not work.

I am making a game where you find cubes by talking to people, I am also a new scripter to lua so sorry if I make a dumb mistake. Ok, for some odd reason my code thinks the boolvalue is false when true.

When boolvalue is checked if true:

script.Parent.Triggered:Connect(function(Player)
	local ToolName = "WhiteCube"
	local item = Player.Backpack:FindFirstChild(ToolName)
	local value = game.ReplicatedStorage.WhiteCube.ininv
		if value.Value == true then
			print("Player has tool in backpack!")
			workspace.Cube1.Transparency = 0
			workspace.Cube1.CanCollide = true
		else
			print("Player does not have tool in backpack!")
			local nocubeui = Player.PlayerGui.Nocubetxt
			nocubeui.Enabled = true
			wait(5)
			nocubeui.Enabled = false
				
		end


end)

When boolvalue.value is set to true:

local dialog = workspace.ballwizard.Hat.Dialog
local part1 = workspace.ballwizard.Hat
local part2 = workspace.ballwizard.Beard
local part3 = workspace.ballwizard.Part

local function onSelected(player, choice)
	if choice == dialog.b1.b2.b3.b4.b5.b6.b7.b8.b9 then
		print ("talked to wizard")
		while true do
			part1.Position = part1.Position + Vector3.new(0,-1,0)
			part2.Position = part2.Position + Vector3.new(0,-1,0)
			part3.Position = part3.Position + Vector3.new(0,-1,0)
			wait(0.1)
		end
		
	end
end

dialog.DialogChoiceSelected:Connect(onSelected)

Any help is appreciated!

1 answer

When the bool values are set, there's a difference between setting it on the client's side and the server's side. If you are setting the value with a local script, then the value will be set on the client's side, meaning the server won't see the change. If the server doesn't see the change, any regular scripts in ServerScriptService won't detect that change either. If you want the bool value to be set on the server's side, then use a RemoteEvent. If you need help on that, just ask me.

1 comment

0

Also, clients can see any changes made on the server's side. Servers can't see changes made by clients.

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