Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

sound:Play() on line 77 keeps looping no matter what I do?

Recently I have taken up the hobby of coding; however it has been a rough start. Thanks to this forum's help, I have been able to script an almost working Summon script for a game. Just as a tested the script for the last run, I ran into a problem where the script loops itself even though function has ended. I figured out somewhat that the problem may be coming from the IsTyping command as nothing happens when I move; however I have now idea how to fix it as I have only been coding for 2 or 3 days and the script is an amalgamation of multiple tutorials and solutions. How do I fix this problem.

Here is the code if it helps (Problem targets: Lines 77 and 13)

local UIS = game:GetService('UserInputService')
local plr = game.Players.LocalPlayer 
local Char = plr.Character or plr.CharacterAdded:Wait()

local key = 'L'

local Anim = Instance.new("Animation")
Anim.AnimationId = 'rbxassetid://4906894017'

local Debounce = true

UIS.InputBegan:Connect (function(Input, IsTyping)
	if IsTyping then return 
		
	end
	local KeyPressed = Input.KeyCode
	if KeyPressed == Enum.KeyCode.L and Debounce then
		Debounce = false
		local LoadAnimation = Char.Humanoid:LoadAnimation(Anim)
		LoadAnimation:play()
		print("The Crimson God Has Been Summoned; Run...")
		local CrimGod = true
		
		-- KONO DIO DA
		
		if CrimGod == true then
	local sound1 = game.Workspace.ChargeUp

	
	wait(2)
	
	sound1:Play()
	local orb = game.Workspace.Part
	
	if orb then
   		local player = game.Players.LocalPlayer
    local character = player.Character or player.CharacterAdded:wait()
    orb.Shape = "Cylinder"
    orb.Material = "Neon"
    local weld = Instance.new("WeldConstraint")
    weld.Parent = workspace
    weld.Part0 = orb
    weld.Part1 = character.HumanoidRootPart
    if player.Character:FindFirstChild("Torso") == nil then --checks to see if player is r15
        orb.Position = Vector3.new (player.Character.LowerTorso.Position.X,player.Character.LowerTorso.Position.Y,player.Character.LowerTorso.Position.Z)
    else --this is what happens if r6
        orb.Position = Vector3.new (player.Character.Torso.Position.X,player.Character.Torso.Position.Y,player.Character.Torso.Position.Z)
    end
end
end
		
		
		local tweenService = game:GetService("TweenService")
		local part = game.Workspace.Part
		local tweeningInformation = TweenInfo.new(
		
		0.5, --length
		Enum.EasingStyle.Cubic, --Easing Style
		Enum.EasingDirection.InOut,
		0, --Times repeated
		false, --Reverse or no?
		0 -- delay for tween
		)
		
		local partProperties = {
			
			Size = Vector3.new(877.04,149.27,80.24);
			Transparency = 1;
			CanCollide = false
		}
		local tween = tweenService:Create(part,tweeningInformation,partProperties)
		tween:Play()
	end
	
	wait(5.34)
	local sound = game.Workspace.ChargeUpBOOM
	sound:Play()
	local exppart = game.Workspace.CrimEXP
	if exppart then

   		local player = game.Players.LocalPlayer
    local character = player.Character or player.CharacterAdded:wait()
    exppart.Material = "Neon"
    local weld = Instance.new("WeldConstraint")
    weld.Parent = workspace
    weld.Part0 = exppart
    weld.Part1 = character.HumanoidRootPart
    if player.Character:FindFirstChild("Torso") == nil then --checks to see if player is r15
        exppart.Position = Vector3.new (player.Character.LowerTorso.Position.X,player.Character.LowerTorso.Position.Y,player.Character.LowerTorso.Position.Z)
    else --this is what happens if r6
        exppart.Position = Vector3.new (player.Character.Torso.Position.X,player.Character.Torso.Position.Y,player.Character.Torso.Position.Z)
    end
end
		
		local tweenService = game:GetService("TweenService")
		local part = game.Workspace.CrimEXP
		part.BrickColor = BrickColor.new("Crimson")
		local tweeningInformation = TweenInfo.new(
		
		0.5, --length
		Enum.EasingStyle.Cubic, --Easing Style
		Enum.EasingDirection.InOut,
		0, --Times repeated
		false, --Reverse or no?
		0 -- delay for tween
		)
		
		local partProperties = {
			
			Size = Vector3.new(877.04,149.27,80.24);
			Transparency = 1;
			CanCollide = false
		}
		local tween = tweenService:Create(part,tweeningInformation,partProperties)
		tween:Play()
		wait (1)
		exppart:Destroy()
		exppart = nil

	
	local part = game.Workspace.Part
	part:Destroy()
	part = nil
	wait(2)
	local character = plr.Character or plr.CharacterAdded:Wait()

	local Anim = Instance.new("Animation")
	Anim.AnimationId = 'rbxassetid://4906431432'
	local LoadAnimation = character.Humanoid:LoadAnimation(Anim)
	LoadAnimation:play()
	
		if game.Workspace.ChargeUpBOOM.IsPlaying then
		wait(2)
		sound:Destroy()
		sound=nil
		return end
	end)

1 answer

✓ Accepted answer

in the propertis of the sound there should be a line looped so turn it off

if it doesnt work try putting

local Anim = Instance.new("Animation")
Anim.AnimationId = 'rbxassetid://4906431432'

local LoadAnimation = character.Humanoid:LoadAnimation(Anim) LoadAnimation:play() sound:Stop()

instead of

if game.Workspace.ChargeUpBOOM.IsPlaying then wait(2) sound:Destroy() sound=nil return end end)

2 comments

0

still doesn't work; here's a video to describe what is happening since I have trouble elaborating stuff over text. https://youtu.be/7LpiHicHVrU

0

Try putting like after sound:play() wait(1) sound:stop()

This discussion is preserved as it was. New answers, comments, and votes are closed.