Ye, it’s in a module script running from StarterPlayerScripts
That makes sense. I don’t really work with network ownership but make sure the client has network ownership over the npc before equipping the tool.
EDIT: Setting network ownership does not seem to fix the problem.
Is the tool anchored, by any chance?
It can only be called by the Server as well anyway, which I can’t do.
As to why it has to be client based;
The NPC’s are loaded by the client, as each player can have different NPC’s selected, that way they don’t see somebody elses NPC.
@emojipasta tool handle is not anchored
Well if the NPCs are loaded from the client that means the client has network ownership over the NPCs and thus setting network ownership will not fix the problem.
EDIT: Maybe make a feature request for equipping tools on humanoids that aren’t their character on the client?
EDIT 2: Try welding the tool to the NPC using WeldConstraints.example.rbxl (36.0 KB)
When I’m lazy, I create an invisible part the size of the Right Hand for R15 or Right Arm for R6. I weld any tool parts to this, then I weld the pseudo-limb to the actual player’s limb.
I’d rather use WeldConstraints since they aren’t a nightmare like welds are.
You can set Grip
property of the Tool
to get the desired effect.
Although, another popular solution is to create invisible part, as @colbert2677 suggested.
Tool equipping should happen automatically so long as both your tools and your NPCs are set up properly. Simply parenting the tool to the NPC should work. My current project does this, so I know it works. It could be possible that the automatic equipping is not happening because it can only be done on the server. I don’t know for sure, so it might be a good idea to test this.
If you need a custom way to weld (e.g. using left hand instead of right) then you can do that using your handle (or a dedicated part in your tool) and parts of the character (or a dedicated part welded so it is position the same as the GripAttachment). There are other ways too, like what other people are suggesting.
Note that using the right hand is recommended, especially if you have animations, because the automatic system is easy and doesn’t require extra work. Animations can compensate if they are two-handed.
Ye, testing with giving the weapons in the server seems to work (without running any animations on the dummy too) but from the client it doesn’t. The weapon has to be given by the client, as the NPC does not exist from the server and is only visible to the client
Images
Testing with an animation + equipping the sword by the server (Tested via Play Solo)
Now testing the way I want it to, equipping weapon from client (Tested via Play Solo, switching between client and server)
Client
Server
As you can see, the NPC does not exist from the Server. NPC has to be purely client based.
I’m not sure if this would work but perhaps you could create the dummy on the server, set it’s ownership (using basePart:SetNetworkOwnership(player)
and simply return the instance with a remote function. This would make the dummy exist globally and wouldn’t require you to heavily edit your existing scripts.
Please prompt me if I’m wrong, I am not sure about this
Not sure if NetworkOwnership will making it client only
Not to sound cocky but why is a client-only character a requirement?
It’s a class menu. So basically, players scroll through the classes, and an NPC pops up to give them an idea of what the class looks like. It has to be client side as if the game has 20 players, there’s no easy way to have 20 individual class set up areas for each player. Also, if 2 players have it open at the same time, if it was done by the server it’d have classes interlapping each other. Client based means that only you can see the selected NPC
Roblox’s ClassicSword
runs on a script and not a local script when it handles animations. I presume there are many more such instances as ROBLOX can’t and doesn’t update their old tools. I don’t see how you can use these animations unless you either
- Make the character server sided or
- Store animations or Ids for each tool
It’s not about running animations, its just about putting the sword onto the character. A sword can have no scripts in it and still be Equipped by the character. The point is to try and weld the tools to the arm, since Equipping won’t work with client sided NPC’s.
Correct me if I’m wrong, but from looking at this thread it doesn’t look to me like you’ve tried welding the handle of the tools to the right hand of the NPC. Would you consider doing that to achieve what you’re looking for?
I have already tried that, here’s the code I used:
local weld = Instance.new('Weld')
if not weld then return end
weld.Part0 = armourClone.RightHand
weld.Part1 = weaponClone.Handle
weld.Parent = armourClone.RightHand
And it resulted in this:
So not gripping the weapons how they were intended to be gripped