How i can make a system for drag other player and control them in the air with the mouse

Hi i want make like a telekinesis power and i want be abe to drag and control other player ine the air i have already a script but i don’t know why it’s dosen’t work also i’m not a advanced scripter then i’m maybe gonna ask question to you if i don’t understand anything

Anyway, here is my script

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local uis = game:GetService("UserInputService")
local camera = workspace.CurrentCamera

local teleEnabled = false
local targetedModel = nil
local maxRange = 25

mouse.Button1Down:Connect(function()
	local target = mouse.Target
	if target and target.Parent:FindFirstChild("Humanoid") then
		teleEnabled = true
		targetedModel = target.Parent.PrimaryPart
		local bp = Instance.new("BodyPosition", targetedModel)
		bp.MaxForce = Vector3.new(5e5,5e5,5e5)
		bp.Position = player.Character.HumanoidRootPart.Position
	end
end)

mouse.Button1Up:Connect(function()
	teleEnabled = false
	if targetedModel and targetedModel:FindFirstChild("BodyPosition") then
		targetedModel.BodyPosition:Destroy()
	end
	targetedModel = nil
end)

mouse.Move:Connect(function()
	if teleEnabled == true then
		if targetedModel then
			local location = camera.CFrame.Position + (mouse.Hit.Position - camera.CFrame.Position).Unit * maxRange
			targetedModel.BodyPosition.Position = location
		end
	end
end)

It’s work on dummy but it’s dosen’t work with player and it dosen’t give me any error in the output

This is because it’s a LocalScript, and the NetworkOwner is set to their client. Set the NetworkOwner to your client if you want this to work, but I recommend doing this all on the server.

Yes but if i make it in the server only one person can be use it

I mean make RemoteEvents to transfer it from the client to the server.

Like every time i move the mouse i fire a remote event?

Well, of course you add a delay between firing the remote event, but yeah.

1 Like

SetNetworkOwner is a server exclusive method.

1 Like