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

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

Asked by 2 years ago

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

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

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.

0
Also, clients can see any changes made on the server's side. Servers can't see changes made by clients. kodymarcey 49 — 2y
Ad

Answer this question