#Having an issue with code where it's not properly detecting the correct value for a bool using IF.

1 messages · Page 1 of 1 (latest)

primal birch
#
--there's more to the script but this is everything you need to focus on
--script 1, Handler
local function fire(player, mouseHitPos, running)

    if firingcooldown == false then
        if tool.Values.CurrentAmmo.Value > 0 then
            if tool.Values.Running.Value == false then -- < Firing even if Running.Value is true. Tested it in studio and the bool value is getting properly set.
            
            end
        end
    end
end

--script 2, remote event handler
--this works fine, I think.
local remote = game:GetService("ReplicatedStorage").Sprinting

local function setRunning(plr, sprinting)
    local character = plr.Character
    if sprinting == true then
        if character:FindFirstChild("Musket") then
            character:FindFirstChild("Musket").Values.Running.Value = true
        else
            return
        end
    else
        if character:FindFirstChild("Musket") then
            character:FindFirstChild("Musket").Values.Running.Value = false
        else
            return
        end
    end
end

remote.OnServerEvent:Connect(setRunning)
primal birch
#

I mean

#

I sure hope it is

#

unless roblox super jank is happening

rancid island
primal birch
rancid island
# primal birch yes

and if you print out the Running value, it shows true just before you check it in the handler?

primal birch
#

probably should've done that first

#

yeah the thing is the running value is indeed getting set to true

#

but for some reason the script is not getting that's it's true

#

explorer shows this

rancid island
primal birch
#

actually let me check something really quickly

#

yep ok

primal birch
rancid island
#

How about in the RemoteEvent handler you print out when you set it to false and true.

primal birch
#

as it turns out

#

i am

#

apparently

#

a fucking moron

#

I was sending the player and sprinting value over the client

inputService.InputBegan:Connect(function (key)
    if key.KeyCode == Enum.KeyCode.LeftShift or key.KeyCode == Enum.KeyCode.RightShift then
        sprinting = true
        running = true
        remote:FireServer(plr, sprinting)
        if char:FindFirstChild("Humanoid") then    
            char.Humanoid.WalkSpeed = sprintSpeed
            if char:FindFirstChild("Musket") then
                char:FindFirstChild("Musket").Values.Running.Value = true
                track:play()
            end
        end
    end
end)```
#

like a dumbass