So currently I am making something that takes a chat message from a player, finds the animation off of it and then finds the id using a similar method, but when finding the id I have to use gsub to cut off the text so I am left with only the id of the animation. then when I try and use it in a string it says
because gsub returns both a string and the amount of times the string pattern was removed. This makes the error with the string. Here are the script segments.
--variables and stuff
local function GetID(Message, Animation, Table)
for i, v in ipairs(Table) do
if string.find(string.lower(v), string.lower(Animation)) ~= nil then
return string.gsub(string.lower(v), string.lower(Animation), "")
end
end
end
--more code
for i, v in ipairs(animations) do
local animation = string.find(string.lower(Message),string.lower(v))
print(animation)
if animation ~= nil then
local animid = GetID(Message, v, animationids)
local animationobject = Instance.new("Animation")
animation.AnimationId = "rbxassetid://" .. tostring(animid) -- error line
game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):LoadAnimation(animationobject)
animation:Play()
end
end
How would you get the string part of the value?