Here I assert the UserId if it doesnt exist it should error out with my assert message but…
Here I assert the UserId if it doesnt exist it should error out with my assert message but…
i dont get the full context of the script, could you provide more?
![]()

okay, so you dont want it to be an error, but print “No UserID was found in TextSource.”?
The thing is, assert should detect that its nil and should error out with custom message. Same with checks i put if not ....UserId then return end and it doesnt save it from an error happening.
k, i think ik what you mean, i gotchu just gimme a minute
local function Sound(msg: TextChatMessage)
local Exists, Reason = pcall(function()
Instance.new(“StringValue”).Value = msg.TextSource.UserId
end)
if not Exists then
warn("No UserID was found in TextSource, " … Reason)
else
local Player = Players:GetPlayerByUserId(msg.TextSource.UserId)
local Head = Player.Character:FindFirstChild(“Head”)
end
end
try this
this is gonna cause some perfomance issues for low end devices im pretty sure
And this is simply not gonna work
Could you tell which line is line 18?
![]()
can u try it tho? im pretty sure itll work
it worked just added something.
I will modify it to cause no memory leaks and look slicker, thanks
ok and heres for less performance issues
local function Sound(msg: TextChatMessage)
local Exists, Reason = pcall(function()
return msg.TextSource.UserId
end)
if not Exists then
warn("No UserID was found in TextSource, " … Reason)
else
local Player = Players:GetPlayerByUserId(msg.TextSource.UserId)
local Head = Player.Character:FindFirstChild(“Head”)
end
end
it uses return so it doesnt have to make a stringvalue
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

