I have made an admin command where you can enable a force field on someone. The admin command is not working, and I tried to print the force field's parent, but it did not print anything in the output.
if Chat:lower():sub(1, #Prefix + #"ff") == Prefix.."ff" then for i, v in pairs(game.Players:GetPlayers()) do if string.match(string.sub(Chat, 7), v.Name) then local ff = Instance.new("ForceField", plr.Character) print(ff.Parent) end end end
How would I make it so it inserts a force field into the target?
You can just use sub
alone.
```lua local code = Code:lower()
if code:sub(1, #Prefix + #('ff')) == Prefix .. 'ff' then -- checks to see if the message is "{prefix}ff" local cut = code:sub(#Prefix + #('ff') + 2) -- returns a cut of the original message from the start of the target in the message
for _,v in pairs(game.Players:GetPlayers()) do local n = v.Name:lower() if n:sub(1, #cut) == cut then -- This can accept partial parts or a player's username. This will check if the cut is equal to a cut of the player's name local ff = Instance.new('ForceField') ff.Parent = v.Character.Torso end end end ```