--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)
#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)
is script 1 on the tool?
well
I mean
I sure hope it is
unless roblox super jank is happening
so is tool = script.Parent.Parent?
yes
and if you print out the Running value, it shows true just before you check it in the handler?
ah that..
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
Which is why I want you to print it, we have to narrow down the issue. Is the value getting reset, is the if statement bad, etc
my bad I forgot to say that yes, the print is saying it's false even while it is true
actually let me check something really quickly
yep ok
the print is saying it's false even though explorer says it is true.
How about in the RemoteEvent handler you print out when you set it to false and true.
ok so
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