I am using a RemoteEvent to change value's globally from a LocalScript, this is for gun. Any suggestions or changes?
LocalScript:
elseif key.KeyCode == Enum.KeyCode.Q and tool:GetAttribute("hasAuto") == true then --Ignore db = false print(mode.Value) if mode.Value > 2 then tool.ModeEvent:FireServer("Mode", 1) --Line I'm having an issue with end tool.ModeEvent:FireServer("Mode", mode.Value + 1) --Works perfectly if mode.Value == 1 then tool.ModeEvent:FireServer("isAuto", false) elseif mode.Value == 2 then tool.ModeEvent:FireServer("isAuto", true) end wait(1) db = true end
Script:
tool.ModeEvent.OnServerEvent:Connect(function(player, value, mode) tool:FindFirstChild(value).Value = mode end)
Local script line 4: change ">2" to ">=2" ?
Edit: actually, what you're doing is checking if a value is 2+ and if it is you're setting it to 1... But then straight afterwards you're setting it back to +1. Maybe move the +1 part into an "else" section of the preceding "if" statement?
elseif key.KeyCode == Enum.KeyCode.Q and tool:GetAttribute("hasAuto") == true then --Ignore db = false print(mode.Value) if mode.Value >= 2 then --changed tool.ModeEvent:FireServer("Mode", 1) --Line I'm having an issue with else --moved tool.ModeEvent:FireServer("Mode", mode.Value + 1) --Works perfectly end if mode.Value == 1 then tool.ModeEvent:FireServer("isAuto", false) elseif mode.Value == 2 then tool.ModeEvent:FireServer("isAuto", true) end wait(1) db = true end