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

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

Asked by
3F1VE 257 Moderation Voter
3 years ago
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

Log in to vote
1
Answered by
TGazza 1336 Moderation Voter
3 years ago

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)
0
Thanks! 3F1VE 257 — 3y
Ad

Answer this question