Hi there! I have looked over this article Strings | Documentation - Roblox Creator Hub and I would like to know if this is possible?
I have a value saved to all players called “PlayerAnim” and everyone has a value for it, like DefaultAnim, or RthroAnim, and when people buy stuff it will load the character and say robloxapp-20210124-1140223.wmv (974.2 KB)
I already added the “ation” by adding,
script.Parent.TextLabel.Text = "You Purchased the " .. player.PlayerAnim.Value .. "ation!!!"
Now what I want to know is, is there a way to count the number of letters (4 would be the number) in the value from back to front(or right to left) and then put a space in between?
Also, in the video I posted, does it come up as something you need to download or something you can just click on and it plays?
I saw that you put three dots instead of the two concatenate dots if that makes a difference, it wasn’t working for me, (the three dots)
12:06:56.420 Players.MRKYLO20.PlayerGui.LoadingScreenGUI.LoadingScreenFrame.LocalScript:8: attempt to concatenate string with nil - Client - LocalScript:8
12:06:56.420 Stack Begin - Studio
12:06:56.420 Script 'Players.MRKYLO20.PlayerGui.LoadingScreenGUI.LoadingScreenFrame.LocalScript', Line 8 - Studio - LocalScript:8
12:06:56.420 Stack End - Studio
If the roblox documentation of string.split would have been right, then splitTable[1] would be “Mage”, splitTable[2] would be “” and splitTable[3] would be “nim”. It should have returned 3 elements, but it only returned 2.
you could make “A” in AstronautAnim, lowercase, if it doesn’t matter for the rest of your code. You could then try making the first letter of the string, uppercase, before printing it, though I am unsure of how to do it.
Edit: But that would also mean that only the first letter can be a capital “A”. To make the code to work with capital "A"s, you need to make
You should check out the string-patterns-reference article to learn how to use Lua’s pattern matching. Here’s an example of how you could solve this problem using string.match:
local function getAnimPurchaseMsg(name)
local animName = string.match(name, "^(.+)Anim$") or
error("Anim was not found at the end of: `" .. name .. "`")
return "You Purchased the " .. animName .. " Animation!!!"
end
print(getAnimPurchaseMsg "PlayerAnim")
print(getAnimPurchaseMsg "DefaultAnim")
print(getAnimPurchaseMsg "RthroAnim")
print(getAnimPurchaseMsg "AstronautAnim")
print(getAnimPurchaseMsg "AnimAnim")
print(getAnimPurchaseMsg "AnimAnimation") -- this should error