I'm going to work on more script with sound change on touch. However, this script doesn't work and shows an error
function onTouched(hit)
local check = hit.Parent:FindFirstChild("Humanoid")
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
local stats = user:findFirstChild("PlayerGui")
if check ~= nil then
print('PlrGui Found')
local soundone = stats:WaitForChild('SoundOne')
local soundtwo = stats:WaitForChild('SoundTwo')
print('Sound Found')
if soundone.IsPlaying and not soundtwo.IsPlaying then
soundone:Stop()
soundtwo:Play()
print('Sound Changed')
end
end
end
script.Parent.Touched:connect(onTouched)
Error: Line 4,attempt to index local 'user' (a nil value)
