Reputation: 11
I have like a ID: MeshID == "rbxassetid://2542637991" then .... How I could do in lua that I can use "MeshID == "rbxassetid://XY" then" , so no need to add the exact number?
if Stuff:IsA("MeshPart") then
if MeshID == "rbxassetid://NUMBER" then
local Distance = game.Players.LocalPlayer:DistanceFromCharacter(Stuff.Position)
if Distance < least and Distance < 250 then
least = Distance
Object = Stuff
end
To add at NUMBER the number found in the code, means
Upvotes: 1
Views: 25
Reputation: 26794
You can use match
function to find the value you need:
if Stuff:IsA("MeshPart") then
local num = tonumber(MeshID:match("rbxassetid://(%d+)"))
if num then -- this will replace `MeshID == "rbxassetid://NUMBER"` check
Upvotes: 1