Hi!
So, I'm scripting a barrage, kind of like in JoJo, and the event that stops the sound that plays when you begin to barrage is firing multiple times. Specifically, the mouse.KeyUp fires multiple times, even though I'm only releasing one key. I've tried to use UIS.InputEnded, but it comes with the same results.
The specific part that is probably broken
if not tobreak then
keyUp = mouse.KeyUp:Connect(function(key)
if key == "e" then
keyUp:Disconnect()
model.PlaySound:FireServer(newsoundE, newsoundE.IsPlaying)
EAnim:Stop()
rightarmHitbox:HitStop()
leftarmHitbox:HitStop()
humanoid.WalkSpeed = settingsModule.defaultSpeed
humanoid.JumpPower = settingsModule.defaultJump
newsoundE:Stop()
print("stopping sound1")
tobreak = true
end
end)
end
The play sound event (the server just fires this event to all players except the one who sent it. If you want that code, just tell me)
RS.PlaySoundClient.OnClientEvent:Connect(function(sound, isPlaying)
print(sound.Name)
if isPlaying then
print("stopping sound"..sound.Name)
sound:Stop()
return
else
print("playing sound"..sound.Name)
local newsound = sound:Clone()
newsound.Parent = sound.Parent
newsound:Play()
wait(newsound.TimeLength)
newsound:Destroy()
return
end
end)
Full barrage script
repeat
local crazyNumber = 0.2
local arm = 1
barragepunches = barragepunches + 1
while true do
if not workspace.InTimeStop.Value or workspace.WhoStoppedTime.Value == plr.Name then
EAnim:AdjustSpeed(1)
break
end
EAnim:AdjustSpeed(0)
wait(.1)
end
if UIS.KeyboardEnabled then
if not tobreak then
keyUp = mouse.KeyUp:Connect(function(key)
if key == "e" then
keyUp:Disconnect()
model.PlaySound:FireServer(newsoundE, newsoundE.IsPlaying)
EAnim:Stop()
rightarmHitbox:HitStop()
leftarmHitbox:HitStop()
humanoid.WalkSpeed = settingsModule.defaultSpeed
humanoid.JumpPower = settingsModule.defaultJump
newsoundE:Stop()
print("stopping sound1")
tobreak = true
end
end)
end
else
if not tobreak then
for i, button in pairs(mobileButtons:GetChildren()) do
buttonUp = button.MouseButton1Up:Connect(function()
if button.Name == "EButton" then
buttonUp:Disconnect()
model.PlaySound:FireServer(newsoundE, newsoundE.IsPlaying)
EAnim:Stop()
rightarmHitbox:HitStop()
leftarmHitbox:HitStop()
humanoid.WalkSpeed = settingsModule.defaultSpeed
humanoid.JumpPower = settingsModule.defaultJump
newsoundE:Stop()
print("stopping sound 2")
tobreak = true
end
end)
end
end
end
if tobreak then
break
end
if arm == 1 then
rightarmHitbox:HitStart()
wait(crazyNumber)
rightarmHitbox:HitStop()
arm = 2
else
leftarmHitbox:HitStart()
wait(crazyNumber)
leftarmHitbox:HitStop()
arm = 1
end
until barragepunches >= settingsModule.punches

1 comment
The output prints "stopping sound1" over 10+ times. It's random