Script help - teleport a player to me

I’m trying to make a summoning script to summon the specified player infront of me, but it’s not working.

Local script: (startercharacterscripts)

wait(2)

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Mouse = Player:GetMouse()
local UserInputService = game:GetService("UserInputService")

repeat
	wait()
until Character.Parent == workspace

local Debounce = false

Player.Chatted:Connect(function(Message)
	local lower = string.lower(Message)
	local Object = nil
	local targetPlayer = nil
	if string.sub(lower, 1, 9) == "i summon, " and not Debounce then
		Debounce = true
		local Target = string.sub(lower, 10, #lower)
		for _,v in next, Players:GetPlayers() do
			if string.sub(string.lower(v.Name), 1, #Target) == Target then
				Object = v.Character.Humanoid
				targetPlayer = v
			end
		end
		if not Object then
			for _,v in next, workspace:GetDescendants() do
				if v.Name:lower() == Target and v:IsA("Model") then
					Object = v
				end
			end
		end
		if targetPlayer then
			game.ReplicatedStorage.AbilityEvents.Summon:FireServer(targetPlayer)
			wait(5)
			Debounce = false
			return
		end
	end
end)

server script: (server script service)

game.ReplicatedStorage.AbilityEvents.Summon.OnServerEvent:Connect(function(Player, targetPlayer)
	print(targetPlayer.Name)

		targetPlayer.Character.HumanoidRootPart.CFrame = Player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -5) * CFrame.Angles(0, 100000, 0)
end)

the line

print(targetPlayer.Name)

doesn’t print anything at all

i am still having this issue unfortunately

image

change the :FireSerer(targetPlayer) to :FireServer(targetPlayer.Name)

and then in ther serverside script try this

game.ReplicatedStorage.AbilityEvents.Summon.OnServerEvent:Connect(function(Player,targetPlayer)
	print(targetPlayer.Name)
	
	local Plr = game.Players:FindFirstChild(Player)
	local TargetPlr = game.Players:FindFirstChild(targetPlayer)
	targetPlayer.Character.HumanoidRootPart.CFrame = Player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -5) * CFrame.Angles(0, 100000, 0)
end)

Would this only fix the print issue, not the teleporting?

This didn’t fix anything.
Nothing printed, they didnt teleport in front of me.

try to check if the remote event is even firing by just adding print(“Hello World”)

I added a print(“Remote fired”) underneath the line where i fire it, and when i pick it up on the server, i printed “Server got remote”

nothing printed

is HTTP requests enabled?
image
under game settings

Yes, HTTP requests are enabled, along with API services

maybe if you’re sending :FireServer(targetPlayer.Name) just print(targetPlayer)

I did that in the original script, nothing printed

image
try deleting the space after the comma

that would make me have to say it like this

i summon,AdSomnum

LOCAL SCRIPT:

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Mouse = Player:GetMouse()
local UserInputService = game:GetService("UserInputService")

repeat
	wait()
until Character.Parent == workspace

local Debounce = false

Player.Chatted:Connect(function(Message)
	print("yes0")
	local lower = string.lower(Message)
	local Object = nil
	local targetPlayer = nil
	print(string.sub(lower, 1, 9))
	if string.sub(lower, 1, 9) == "i summon," and not Debounce then
		print("yes1")
		Debounce = true
		local Target = string.sub(lower, 11, #lower)
		print(Target)
		for _,v in next, Players:GetPlayers() do
			if string.sub(string.lower(v.Name), 1, #Target) == Target then
				Object = v.Character.Humanoid
				targetPlayer = v
			end
		end
		if not Object then
			for _,v in next, workspace:GetDescendants() do
				if v.Name:lower() == Target and v:IsA("Model") then
					Object = v
				end
			end
		end
		if targetPlayer then
			print("yes2")
			game.ReplicatedStorage.AbilityEvents.Summon:FireServer(Player.Name,targetPlayer.Name)
			wait(5)
			Debounce = false
			return
		end
	end
end)

SERVERSCRIPT:

game.ReplicatedStorage.AbilityEvents.Summon.OnServerEvent:Connect(function(pass,Player,targetPlayer)
	local Plr = game.Players:FindFirstChild(Player)
	
	print(Plr.Name)
	print(Plr.Name)
	local TargetPlr = game.Players:FindFirstChild(targetPlayer)
	TargetPlr.Character.HumanoidRootPart.CFrame = Plr.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -5) * CFrame.Angles(0, 100000, 0)

end)

i tried this and it worked, the problem was with the space in the if statement and then i changed line 23 from 10 to 11. and some adjustments in server script but that was with the remote event., delete the yes0 and the rest, that was just to see if the if statements fired

right… but do i have to say

i summon,AdSomnum
or can i do
i summon, AdSomnum

it works with i summon, AdSomnum

okay thanks! i will try it.

chars