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

Attempt to index nil with 'Stop'?

local stage = game:GetService("Players").LocalPlayer.leaderstats.Stage
local sound = {2629666914, 1943645778, 3094708023, 1797517374, 2559967558, 1796267247}
	if game.Workspace:FindFirstChild("e") == nil then
    soundObject = Instance.new("Sound",workspace)
	soundObject.Name = "e"
	local random1 = math.random(1,6)
	soundObject.SoundId = "rbxassetid://"..sound[random1]
	soundObject.Looped = true
	soundObject:Play()
	end
    stage:GetPropertyChangedSignal("Value"):Connect(function()
	if stage.Value == 1 then
		soundObject:Stop()
		soundObject.SoundId = "rbxassetid://"..sound[1]
		soundObject:Play()
	else if stage.Value == 9 then
		soundObject:Stop()
		soundObject.SoundId = "rbxassetid://"..sound[2]
		soundObject:Play()
	else if stage.Value == 21 then
		soundObject:Stop()
		soundObject.SoundId = "rbxassetid://"..sound[3]
		soundObject:Play()
	else if stage.Value == 31 then
		soundObject:Stop()
		soundObject.SoundId = "rbxassetid://"..sound[4]
		soundObject:Play()
	else if stage.Value == 41 then
		soundObject:Stop()
		soundObject.SoundId = "rbxassetid://"..sound[5]
		soundObject:Play()
	end
	end
	end
	end
	end
end)

It's really inconsistent, I keep getting Players.CrypxticDoge.PlayerGui.LocalScript:18: attempt to index nil with 'Stop'

1 comment

0

isnt it "Pause" not "Stop" ? i might be wrong

1 answer

it seems like ur not showing the whole script cuz u have 5 ends at the bottom and then an end). I'm guessing the problem is due to somewhere else in the script. all those ends probably mess up the way u think its going to run

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