Turning players into objects to be used

I don’t need help with specific code, i just kind of need some help getting started writing some, for what I want to do, I want to have a system sorta like Soul Eater: Resonance, where one player has one role and another player has a separate role, one is a weapon, one is like the weapons user, I want to write something where the game code recognizes a players role, and if they have the “weapon” role, and they are “in a party” together it will transform the player under the “weapon” status into a literal weapon and then send that weapon model(the weapon player) into the weapon users hand where they can user the weapon the got like an actual weapon, that deals damage and has moves and abilities, obviously I know I need to start off with filtering a team system so a player can decide if they want to be a weapon or a weapon user, but beyond that, where would I begin transforming people into these weapons to be used.

So, I’ll let you sort out the team selection and such, that should be relatively easy.

  • There are a few options:
    • Create a custom character for the weapons (kind of pointless because its more work)
    • Simply set camera to the weapon (probably more performant and easy to implement anyway)
    • Make both players share one model, or parts of one (I wouldn’t recommend this)

Naturally, pick the most efficient one. In this case, setting the ‘weapon players’ camera to the weapon is probably the most reasonable.

  • After all, a weapon can’t walk, jump, or move etc. All they need to do is be present with their ‘user’

Okay, so that’s already the most confusing part simplified. We just need to have a weapon now.

local tool = [your weapon model]
local event = [your path to a remote event]

[ fill in code after a player picks the weapon team ]
* in this case, all we need to continue is:
   * player A (the weapon, most relevant)
   * player B (the user, ill cover this later on!) 

event:FireClient(playerA, tool.[PICK A GOOD PART TO SET CAM TO])

I’ll go back to getting player A and B later on, but for now this is all we need.
Now, what does that event fire to?

**Local Script!**
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera

event.OnClientEvent:Connect(function(target)
    if not target then return end -- this shouldn't give you issues, but prevent this from running if model is nil!
    camera.CameraType = Enum.CameraType.Scriptable -- technically should change this
    camera.CameraSubject = target -- focuses on the given part
end)

Essentially, this code just takes the given part and sets PlayerA’s camera to it. Simple, right!

Back to our server script:

local parties = {} -- create a way to store duos
local tool = [your weapon model] -- make sure its actually a tool
local event = [your path to a remote event]

[ fill in code after a player picks the weapon team ]
* in this case, all we need to continue is:
   * player A (the weapon, most relevant)
   * player B (the user, ill cover this later on!) 

event:FireClient(playerA, tool.[PICK A GOOD PART TO SET CAM TO])
table.insert(parties, {Weapon = playerA, User = playerB})

All we did here was create a place to store our parties.

There are several ways you can interpret it from here. It sounds like the only necessary code is just having an ability system, which I will not provide you.

So the next step is to give that tool to the user.

local parties = {} -- create a way to store duos
local tool = [your weapon model]
local event = [your path to a remote event]

[ fill in code after a player picks the weapon team ]
* in this case, all we need to continue is:
   * player A (the weapon, most relevant)
   * player B (the user, ill cover this later on!) 

table.insert(parties, {Weapon = playerA, User = playerB})
for _, tool in playerB.Character:GetChildren() do
   if tool:IsA("Tool") then tool.Parent = playerB.Backpack end -- remove equipped tools already
end
local ourtool = tool:Clone(); ourtool.Parent = PlayerB.Character

-- do this after tool is given, also reorganize code too
event:FireClient(playerA, ourtool.[PICK A GOOD PART TO SET CAM TO])

We now just reorganized the code so the tool is set up first, and we cloned the tool because I had forgot to do so before.

Your framework is nearly done, there’s just one step I’d suggest here:

local parties = {} -- create a way to store duos
local tool = [your weapon model]
local event = [your path to a remote event]

[ fill in code after a player picks the weapon team ]
* in this case, all we need to continue is:
   * player A (the weapon, most relevant)
   * player B (the user, ill cover this later on!) 

table.insert(parties, {Weapon = playerA, User = playerB})
for _, tool in playerB.Character:GetChildren() do
   if tool:IsA("Tool") then tool.Parent = playerB.Backpack end -- remove equipped tools already
end
local ourtool = tool:Clone(); ourtool.Parent = PlayerB.Character

ourtool.Unequipped:Connect(function()
       event:FireClient(playerA, playerB.PrimaryPart)
end)
ourtool.Equipped:Connect(function()
       event:FireClient(playerA, ourtool.[PICK A GOOD PART TO SET CAM TO])
end)

-- do this after tool is given, also reorganize code too
event:FireClient(playerA, ourtool.[PICK A GOOD PART TO SET CAM TO])

Now if the tool is unequipped, the camera will simply be set to the player’s HRP and vice versa when equipped.
I realized I also promised some team picking code, but in respect to the forums I won’t give away too much. If you need help, you can ask in a reply.

Great, so your now set up to make abilities and such.

  • Fire an event when certain move keys are pressed, most of this is client work here.
  • Simply check if the player is a “Weapon” in a table, and if they are ‘equipped’ in the User’s character model.
  • If both are true, you just run whatever ability code from there
  • Ask questions if you need help!

Thank you so much. I really appreciate the guidance as well as the fast response. Please correct me if I’m wrong, because I’m not the most experienced, but from what I can understand, this all would require the “weapon” to kinda just be along for the ride, doing things such as setting a camera position so the weapon could see what was happening. That doesn’t really strike me, personally, as a great incentive to be a weapon. Who would want to watch a fight when they could be the one fighting? I already have plans to give both weapons and their users fighting capabilities of their own, as a means to level up without really needing a friend to do so. Regardless of that, when the two are working as a pair, I would like to give them both the same HP bar, making it feel as if they are really working as one. Of course, they will be able to split and have their own health and stamina bars on their own. However, when they are paired, the weapon user gets to engage in the fighting, and I feel like making the weapon watch seems kind of boring for the weapon player. So, instead, how would I approach this in a way that makes the weapon’s physical player teleport to an alternate “realm” while the weapon user uses the weapon form to fight? The purpose of sending the player’s body to a different “realm” would be that the weapon, in that state, could do things such as guitar hero-themed mini-games to give the pair an increase in stats. I feel like this would make the experience for both players more enjoyable and give them an actual incentive to party. I know a bit off-topic, but I’m just kind of shooting around, seeing what would and would not be possible.

Well, you of course can link all of those things.

  • If you link healthbar, give abilities, etc, they can REMOTELY control those.
    • you need nothing more than a camera to ‘become’ a sword. Believe it or not, life really is that simple here.
    • when you think about it, what is a player character? its just a model that the camera follows and key inputs control it. There is no other steps needed.

Setting the camera simply does this: it lets them watch.

  • If you wish to implement all that extra stuff, you’d essentially do this:

After setting the camera with the remote event:

  1. Create some buttons or other GUI objects that will later work.
  • Ex. Attack, ability 1, ability 2, wtv
    • This is where you could allow them to switch between the shadow realm and viewing the sword
  • Lets cover that first actually, a camera button.
make two buttons, each having this localscript
local button = path here
button.Activated:Connect(function()
    player.CameraSubject = OBJ OF WHATEVER THE BUTTON IS FOR
end)
  • So in the first button, subject will be set to the player’s character.humanoidrootpart. In the second, you could retrieve the weapon model from earlier and re-set it
  • So now we can view both the actual player and the weapon.
    • What about making them appear in the shadow realm itself
-- insert this in the previous server script, before setting camera originally
playerA.Character:PivotTo(CFrame.new(Vector3.new(X point, Y point, Z point))
  • this assumes you have the realm built somewhere, by the way.
  • next up, linking HP. Place this anywhere before the fireclient in server
playerB.Character.Humanoid.HealthChanged:Connect(function(h) 
       playerA.Character.Humanoid.Health = h -- links their hp together
end)
  • Okay, all that leaves is your other minigames and stuff. Yeah, thats all gonna be making more GUI buttons that just run minigames you are gonna have to make yourself.
  • Just keep using the activated event on buttons, then run the game and give buffs if necessary

You did also mention a desire to give the weapon abilities, once again thats just gonna be a button or a key input (use ContextActionService, search how to do this) to bind keys

  • then fire to server and check if they are a weapon in the parties table and if the weapon is equipped.
  • Also check on the client if they are viewing the weapon, just for immersion.

I also request you to mark one of these posts as the solution. I will continue replying, but it will inform others the question was ‘solved’.