Separating a string

I’ve been trying to create a kind of “admin” per se but I’m kind of having trouble finding out how to get it to separate

Basically when you say : create portal or something (name of part in the workspace) it should clone a particle there, my main issue is the finding

The client portion I have no idea on.

Client :

	if Message == "Words" then
		game.ReplicatedStorage.Events.SpellEvents.Portal:FireServer(game.Players.LocalPlayer,"PartNameHere") -- You fire the server with the part name so the server can create the effect

I haven’t really found anything that’s easy to understand for me personally

  1. No need to provide the sender(player) as the first argument on FireServer, it automatically does that for you.

2.Do you try to insert an effect on the server on the given part name?

My problem was less with the effect and more on separating the Partname with the string for example

if you say “Effect Part1” I would have no idea how to separate the “Part1” from the “Effect” it and I’m trying to make it clean and not add a billion if statements

1 Like

You could use string.split, which returns you a table of separated strings with a given key(e.g: commas).

But you could use string.match to find a certain word(s) and remove it / ignore it, etc.

In this example:

local word = "Effect PartName"
local Needed = word:match("PartName")

Or, you could use string.sub

local word = "Effect PartName"
local Needed = word:sub(8,15)
local Needed = word:sub(8,#word:match("PartName"):len())
1 Like

Thank you I will try and research this further have an amazing day!!

1 Like

One more question sorry, there’s going to be multiple parts so how would I go about separating between

PartName and a theoretical PartName2 while still requiring a starting phrase.?

You could still use string:match to find any word you want.

If you have something like this:
“Hey, I have parts,PartOne,PartTwo”

You could use string:split(",") and it’ return a table containing words seprated by a comma in this case,
And then:
lets say you have:

local mytab = string:split(",")
print(mytab[3]) – would print “PartOne”

1 Like