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

How do I remove errors from this script when I chat a string instead of numbers?

local e = Instance.new("Sound",workspace) game.Players.dimondflash57.Chatted:Connect(function(plr) if plr == not string then e.Playing = true e.SoundId = "rbxassetid://"..tonumber(plr) e.TimePosition = 0 e.Looping = true end end)

The error says "Unable to compensate string with nil" I don't want this showing because I use it in developer console and I run a lot of scripts there.

1 answer

✓ Accepted answer

try this:

local ME = game.Players:WaitForChild("dimondflash57",30) -- Change this to your username

local e = Instance.new("Sound",workspace) 
ME.Chatted:Connect(function(mess)
	
	if tonumber(mess)~= nil then 
		e.SoundId = "rbxassetid://"..tonumber(mess) 
		e.TimePosition = 0 
		e.Looped = true
		e:Play()
	end 
end)

1 comment

0

Thanks!

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