error:Unable to assign property DisplayName. string expected, got table

script

local rep = game:GetService("ReplicatedStorage")
local folder = rep:WaitForChild("Folder")
local rem = folder:WaitForChild("RemoteEvent")
local ghost = folder:WaitForChild("ghost")

rem.OnServerEvent:Connect(function(plr)
	local  char   = plr.Character or plr.CharacterAdded:Wait()
	local humrp   = char:WaitForChild("HumanoidRootPart")
	local clone1  = ghost:Clone()
	local clone2  = ghost:Clone()

	local hum1 = clone1.Humanoid
	hum1.DisplayName = string.split(plr.Name,"Ghost")
	local humrp1  = clone1.HumanoidRootPart
	local humrp2  = clone2.HumanoidRootPart
	clone1.Parent = workspace
	clone2.Parent = workspace
	humrp1.CFrame = humrp.CFrame  * CFrame.new(6,0,0)
	humrp2.CFrame = humrp.CFrame  * CFrame.new(-6,0,0)

	print("OK")
	end)

error message:

Unable to assign property DisplayName. string expected, got table 

string.split returns a table, check the docs here for more information string

1 Like

string.split() will for example, with the inputs “hello there” and “e” will return the output {“h”, “llo th”, “r”}

1 Like

how do i space this out then?

	local message = plr.Name.."Ghost"

What do you mean by space this out?

1 Like

If this were my name it would output kilesixGhost, if you mean space out by adding a space in between you would simply just change "Ghost" to " Ghost"

1 Like