Need help on character control mechanism

I’m trying to make a mind control module but need to know something. Okay so for example I have plr1 and he wants to control plr 2 minds and control his body and etc. How would I be able to change the standard character control from plr1 to plr2 and be able to move with plr2 ? but I still want the plr1 body to be there but just not moving

1 Like

This is honestly an interesting idea. I really think that this is new mechanic. What I am about to write is what I believe that achieve what you want. Basically, it is solely only my idea.

There are 2 cases of this mechanic.

  1. plr2 is an actual player.
    I don’t think that you can mind control an actual player. Maybe? you can try using RemoteEvent sending to server that you want to mind control plr2. Then, after the server approves, the server will set up ContextActionService of these following buttons; W,A,S,D, Spacebar, or any buttons that you use to control movement mechanisms. The server will also need to override your default movement, so you yourself cannot move. Instead, when you move, you will move plr2 instead.

  2. plr2 is a dummy
    This has more potential of success. You need to setup animations for movements inside that Dummy also. After that, you can use the same approach as the first scenerio to achieve what you want.

Note: This is only my idea, and I’ve never tried it myself. But good luck! Interesting idea.

I have a tricky solution, it might not work.
So you set the character of the Player to the mind-controlled Player like this:

local clonedChar = plr1.Character:Clone()
clonedChar.Parent = workspace -- since you want the players character to still be there you can do that 
plr1.Character = plr2.Character

And then on the client, get plr2’s PlayerModules and find the ControlModule and then disable the character like this:

local playerscripts = plr2.PlayerScripts
local playermodule = require(playerscripts:WaitForChild("PlayerModule"))
local controls = playermodule:GetControls()
controls:Disable()

And then, finally, set plr1’s camera to plr2’s camera on the client

so I’ve found 2 problems with this. Firstly the plr that gets his mind controlled is not a real player it’s a dummy so I can’t disable his controls but I tried to do the plr1.Character = plr2.Character it’s working but uh weirdly… I’ve also found a problem. When the player change character if the mind controller is walking he just continues walking in the direction he was supposed to do

Set the NPC’s humanoid’s WalkSpeed to 0 and the JumpPower to 0.
I don’t know if this would affect the player’s character or not.

alr that worked thank you! But also I have still some questions so basically its an fps camera so how can I change the camera from the head of the plr1 to the head of the dummy2?

Just do workspace.CurrentCamera.CameraSubject = npc.Humanoid on the client

This might seem a tedious task mainly due to replication, but the first steps would be easy as you can just disable the controls for the victim while having the controller view on them.
You might also take mobile controls in consideration too.

alright it’s working pretty well there just 1 last problem when i change to the dummy sometime i need to change 3 or 2 time before I’m able to move the character normally

Maybe its a problem with the dummy model?

here a video so you can see what I’m talking about

so im trying to move the character but it’s just not working

1 Like

Can I see what you have so far in your script?

1 Like
local player = game:GetService('Players').LocalPlayer
local Plrmodel1 = game:GetService('Workspace'):WaitForChild(player.Name)
local plrmodel2 = game:GetService('Workspace'):WaitForChild('NPC')
local useri = game:GetService('UserInputService')

useri.InputBegan:Connect(function(input)
	local playerscripts = player:WaitForChild('PlayerScripts')
	local playermodule = require(playerscripts:WaitForChild("PlayerModule"))
	local control = playermodule:GetControls()

	if input.KeyCode == Enum.KeyCode.F then
		print('switch')
		player.Character:WaitForChild('Humanoid').WalkSpeed = 0
		player.Character:WaitForChild('Humanoid').JumpPower = 0 
		plrmodel2:WaitForChild('Humanoid').WalkSpeed = 16
		plrmodel2:WaitForChild('Humanoid').JumpPower = 50.145
		--control:Disable()
		player.Character = plrmodel2
		workspace.CurrentCamera.CameraSubject = plrmodel2.Humanoid
		--control:Enable(true)
	end
	if input.KeyCode == Enum.KeyCode.E then
		player.Character:WaitForChild('Humanoid').WalkSpeed = 0
		player.Character:WaitForChild('Humanoid').JumpPower = 0
		Plrmodel1:WaitForChild('Humanoid').WalkSpeed = 16
		Plrmodel1:WaitForChild('Humanoid').JumpPower = 50.145

		print('switch')
		player.Character = Plrmodel1
		workspace.CurrentCamera.CameraSubject = Plrmodel1.Humanoid

	end
end)

Maybe remove this part? I don’t really know what is wrong with this script

1 Like

I tried doesn’t work. right now I’m trying to make a initialisation script for the NPC

Yo, I’ve found out why it was doing that!! So basically it was a server error basically the controlled NPC was being controlled on the client and not the server so I had to change the humanoidrootpart network owner to the player!

Thank you @hasoco @Jacky2804 @weakroblox35 for helping!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.