-
What do you want to achieve? Kinda hard to explain, I want the character to spawn with a sword in their hands (Not gear!). I want to try to use welds and have it attached in a reasonably way to the right arm.
-
What is the issue? I don’t know any way to do this, I am not expecting scripts, rather suggestions. I want the character to spawn with their own appearance, so startercharacters are off the menu for me, unless there is a way I can carry the appearance of the character over to the startercharacter, sounds complicated.
-
What solutions have you tried so far? I have not found any sources to my knowledge, so I am kinda stuck. I don’t have any script to go by.
So if u dont want to use tools (gear) then the second option is welding. In this tutorial it is explained how to animate models, but also gow to weld them to the hand: How to animate Tool Parts (Guns, Knifes etc.)
What I would do is this:
Add an invisible part the size and shape of an R6 arm positioned to “hold” the sword, and use that as the sword’s PrimaryPart.
When the player’s CharacterAdded event fires, clone the sword into the player character, call SetPrimaryPartCFrame on it and pass in the CFrame of the player’s arm as the parameter. Then weld the sword to the arm.
It could look something like this:
local players = game:GetService("Players")
local sword = game:GetService("ServerStorage")["Sword"]
local function giveSword(character)
local arm = character:WaitForChild("Right Arm", 1)
if (arm ~= nil) then
local s = sword:Clone()
s.Parent = character
s:SetPrimaryPartCFrame(arm.CFrame)
local w = Instance.new("WeldConstraint")
w.Part0 = arm
w.Part1 = s.PrimaryPart
w.Parent = s
end
end
local function connectPlayer(player)
if (player.Character ~= nil) then -- if they already spawned
giveSword(player.Character)
end
player.CharacterAdded:Connect(giveSword)
end
-- in the rare chance that players are in the game before the script runs
for _, player in ipairs(players:GetPlayers()) do
connectPlayer(player)
end
players.PlayerAdded:Connect(connectPlayer)
Where would this script be located? In StarterCharacterScripts or ServerScriptStorage?
ServerScriptService, and the sword model would be in a place like ServerStorage