Помогите со скриптом Roblox Studio
Я делаю свою систему оружия и столкнулся с проблемой с эффектами, они просто не успевают пропадать, у меня сделано так:
1234567891011121314
mouse.Button1Down:Connect(function()
holdingMouse = true
while holdingMouse and not cooldown do
cooldown = true
barrel.Fire.Enabled = true
barrel.Flash.Enabled = true
shootTrack:Play()
sounds.FireSound:Play()
task.wait(.1)
cooldown = false
barrel.Fire.Enabled = false
barrel.Flash.Enabled = false
end
end)
Если поможете буду благодарен
По дате
По Рейтингу
123456789101112131415161718192021222324
mouse.Button1Down:Connect(function()
holdingMouse = true
while holdingMouse and not cooldown do
cooldown = true
barrel.Fire.Enabled = true
barrel.Flash.Enabled = true
shootTrack:Play()
sounds.FireSound:Play()
task.delay(0.07, function()
barrel.Fire.Enabled = false
barrel.Flash.Enabled = false
end)
task.wait(0.2)
cooldown = false
end
end)
mouse.Button1Up:Connect(function()
holdingMouse = false
end)
123456789101112131415161718192021222324252627282930
local function playEffects()
barrel.Fire.Enabled = true
barrel.Flash.Enabled = true
shootTrack:Play()
sounds.FireSound:Play()
-- Эффекты отключаются спустя короткое время
task.delay(0.1, function()
barrel.Fire.Enabled = false
barrel.Flash.Enabled = false
end)
end
mouse.Button1Down:Connect(function()
holdingMouse = true
while holdingMouse do
if not cooldown then
cooldown = true
playEffects()
task.wait(0.5) -- Задержка перед следующей стрельбой
cooldown = false
else
task.wait(0.01) -- Короткая пауза, чтобы избежать переполнения цикла
end
end
end)
mouse.Button1Up:Connect(function()
holdingMouse = false
end)
123456789101112131415161718192021
mouse.Button1Down:Connect(function()
holdingMouse = true
while holdingMouse do
if not cooldown then
cooldown = true
barrel.Fire.Enabled = true
barrel.Flash.Enabled = true
shootTrack:Play()
sounds.FireSound:Play()
task.wait(0.1)
barrel.Fire.Enabled = false
barrel.Flash.Enabled = false
task.wait(0.5) -- Задержка перед следующей стрельбой
cooldown = false
end
end
end)
mouse.Button1Up:Connect(function()
holdingMouse = false
end)
Больше по теме