Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

attempt to index a nil value Sound Err?

Asked by
lytew 99
4 years ago

an error is happening in my sound variable .. the error is Players.lytew.PlayerScripts.dontsave_test: 13: attempt to index a nil value script:

local debounce1 = false
local work = game:GetService("Workspace")
local hitbox = work.all_lavas.hit_box
hitbox.Touched:connect(function(hit)
wait(1.5)
if debounce1 == false then
print('debounce false')
debounce1 = true
local gui = script.Parent.Parent.PlayerGui
local texto = 'Dont save Creyson'
local player = game:GetService("Players")
local soundclick = 'rbxassetid://1238528678'
local sound = player:GetPlayerFromCharacter(hit.Parent).PlayerGui.Soundclick

local findplayer = player:GetPlayerFromCharacter(hit.Parent)

if findplayer and findplayer.Character and findplayer.Character:FindFirstChild('Humanoid') then

local textscreen = script.localtext_dontsave:Clone()
textscreen.Parent = player:GetPlayerFromCharacter(hit.Parent).PlayerGui

print(findplayer.Name)
for i = 1,#texto do
wait(0.09)

player:GetPlayerFromCharacter(hit.Parent).PlayerGui.localtext_dontsave.TextLabel.Text = string.sub(texto,1,i)
sound:Play()
sound.Volume = 1




if player:GetPlayerFromCharacter(hit.Parent).PlayerGui.localtext_dontsave.TextLabel.Text == 'não salve creyson' then
    wait(1)
    player:GetPlayerFromCharacter(hit.Parent).PlayerGui.localtext_dontsave.TextLabel.Text = 'não salve creyson :('

    sound:Play()
    sound.Volume = 1

    wait(8)
    player:GetPlayerFromCharacter(hit.Parent).PlayerGui.localtext_dontsave:Destroy()

    wait(2)
    debounce1 = false
end
end
end 
end
end)

error is happening in Line 13

Answer this question