I am trying to make a script where when you click a player, they fly to you (not teleport), right now, it is a tool with a local script that when you click a person, it sends over the Mouse.Hit and Mouse.Target to a server script, but I keep getting the error Hit is not a valid member of CFrame. Here are the scripts.
Local script
local Tool = script.Parent
local Player = game.Players.LocalPlayer
local Cooldown = false
local CDTime = 5
local Mouse = Player:GetMouse()
Tool.Activated:Connect(function()
if Cooldown then return end
if Mouse.Target == nil then return end
print(Mouse.Target)
spawn(function()
Cooldown = true
wait(CDTime)
Cooldown = false
end)
Tool.RemoteEvent:FireServer(Mouse.Hit, Mouse.Target)
end)
Server Script
local Tool = script.Parent
local Cooldown = false
local CDTime = 10
Tool.RemoteEvent.OnServerEvent:Connect(function(Player, Mouse)
if Cooldown then return end
local char = Player.Character
local root = Player.Character.HumanoidRootPart
spawn(function()
Cooldown = true
wait(CDTime)
Cooldown = false
end)
local bp = Instance.new("BodyPosition")
bp.Position = root.Position
bp.MaxForce = Vector3.new(1e9,1e9,1e9)
bp.Parent = Mouse.Hit.Parent
game.Debris:AddItem(bp,2)
end)

4 comments
Thanks, you gave me a lot of information to work with. I changed the local script to only mouse.target, and I changed the server script line 21 to mouse.Target, but now I am getting the error "Target is not a valid member of Part"
Change the server script line 21 to just mouse. The LocalScript is fine. You've confused yourself with your variable names. I don't think you can actually pass the entire mouse object through a remote, since it's non-replicated, but you CAN pass CFrames and replicated parts. A better name for the parameter would be "MouseTarget", since that's what you pass into it.
I get it now, I'm passing mouse.Target to the server script as mouse, so I was doing Mouse.Target.Mouse.Target. Thanks so much.
Glad I could help :D