local script: when the left arrow key is pressed a bool value is set to true and is set back to false when it is released
-- The local script--
local uis = game:GetService("UserInputService")
local sm = game.Workspace.valfolder.shootmain --bool val
uis.InputBegan:Connect(function(input)
if input.KeyCode==Enum.KeyCode.Left then
print("Then left pressed")
sm.Value = true
game.ReplicatedStorage.fireshot:FireServer()
end
end)
uis.InputEnded:Connect(function(input)
if input.KeyCode==Enum.KeyCode.Left then
sm.Value = false
print("left arrow remote event start")
end
end)
server script: when the value becomes true, the RunService begins but the issue occurs when the value is set to false it does not stop.
local sm = game.Workspace.valfolder.shootmain --bool val
local runService = game:GetService('RunService')
local Stepped
game.ReplicatedStorage.fireshot.OnServerEvent:Connect(function(player)
Stepped = runService.Stepped:Connect(function()
if sm.Value == false then
print('Printing')
if sm.Value == true then
wait(.5)
Stepped:Disconnect()
end
end
end)
end)
ps. how can I add a wait in the RunService so the print has a wait?

1 comment
thx