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
5 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:

01local debounce1 = false
02local work = game:GetService("Workspace")
03local hitbox = work.all_lavas.hit_box
04hitbox.Touched:connect(function(hit)
05wait(1.5)
06if debounce1 == false then
07print('debounce false')
08debounce1 = true
09local gui = script.Parent.Parent.PlayerGui
10local texto = 'Dont save Creyson'
11local player = game:GetService("Players")
12local soundclick = 'rbxassetid://1238528678'
13local sound = player:GetPlayerFromCharacter(hit.Parent).PlayerGui.Soundclick
14 
15local findplayer = player:GetPlayerFromCharacter(hit.Parent)
View all 49 lines...

error is happening in Line 13

1 answer

Log in to vote
0
Answered by
Arj783 72
5 years ago
Edited 5 years ago

You stated in line 11 that Player was a service. Later you are trying to (In line 13) get the player from the character. You're trying to get the player from the service. You should do -

1local Player = game.Players.LocalPlayer

Hope that helps!

0
what is the difference between service and Get? lytew 99 — 5y
0
You can't compare them. What I am saying is that you said that the Player variable was a service. GetPlayerFromCharacter can only be performed on a character model. It's like trying to get the player from the workspace, if you understand. Which would be implying that you think that workspace is a player. Arj783 72 — 5y
Ad

Answer this question