i tried and tried, for some reason, i want it to go to the attachment, but how can i do that? if i do ON the right arm, it will bug and… you know what will happen
There are different welders. I’m talking about the kind you add to your bar with a addon. You can weld about anything together using them.
Oh, so you’re talking about R6.
In that case, do what I’ve written but put the weld’s C1 as the right grip attachment’s CFrame.
local weld = Instance.new("Weld")
weld.Part0 = Flashlight.PrimaryPart
weld.Part1 = Character.RightArm
weld.C1= Character.RightArm.RightGripAttachment.CFrame
Haven’t tested it, but it should work.
It didn’t work, here’s the code:
FlashlightMeshClone.Parent = workspace
local weld = Instance.new("Weld")
weld.Part0 = FlashlightMeshClone
weld.Part1 = Character:FindFirstChild("Right Arm")
weld.C1= Character:FindFirstChild("Right Arm").RightGripAttachment.CFrame
FlashlightAnimation:Play()
why is it not working AAAAAAAAAAAAAAAA
--local script
local rst = game:GetService("ReplicatedStorage")
local flashlight = rst:WaitForChild("Flashlight")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local rightHandAttachment = character:WaitForChild("RightHand")
flashlight.CFrame = rightHandAttachment.CFrame * CFrame.new(0, 0, 0.1)
flashlight.Parent = rightHandAttachment
local weldConstraint = Instance.new("WeldConstraint")
weldConstraint.Parent = flashlight
weldConstraint.Part0 = flashlight
weldConstraint.Part1 = rightHandAttachment
Have to mess with this command for correct placement: CFrame.new(0, 0, 0.1)
ehhh, i give up always has to be that limit word
Programmers don’t give up, they just lose sleep.
This works, put this script in StarterPlayer.StarterPlayerScripts or StarterGui as a local script.
Then put your flashlight in ReplicatedStorage. This line here can move it to where you want it to be in the hand: CFrame.new(0, 0, 0.1) ← but you’ll have to try a few times to see what works for you.
ok, i’m not gonna give up, but i’m gonna take a break, i’m already makinga game with my friend sooo, yea, i will try that later
First, I recommend setting FlashlightMeshClone’s Parent to the character, and also setting a parent for the weld, which you didn’t do.
weld.Parent = Character:FindFirstChild("Right Arm")
Oh, I actually did tried to attach part to an arm but you have to do some magician in your code and in studio.
So here some steps to answer your question:
- Position your part to specific spot (in example, I placed Bloxy Cola to the Right Arm):
- For preview and best result, weld your part to arm earlier, so you can have visual representation on how your part will look like when being attached. To weld both part together, use this plugin:
- So, after we attached parts, the weld should appear somewhere in the character. After finding it, get to it’s property and remember C0’s CFrame, C1’s CFrame and Part0 with Part1. It will be needed it for coding part. Here what we have in my case:
- Last yet step, create a weld in code (script can be server or local but I prefer it to be server) and put all of the info about property of our weld that we had in previous step. Bloxy Cola was in ReplicatedStorage, so i can just clone it and insert it inside of Right Arm of our player’s character:
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local PartToClone = game.ReplicatedStorage.BloxyCola
local PartToAttach0 = PartToClone:Clone()
local PartToAttach1 = Character:WaitForChild("Right Arm")
PartToAttach0.Parent = PartToAttach1
function rad(x: number)
return math.rad(x)
end
local Weld = Instance.new("Weld")
Weld.C0 = CFrame.new(Vector3.new(0, 0, 0)) * CFrame.Angles(rad(90), rad(0), rad(0))
Weld.C1 = CFrame.new(Vector3.new(-0.011, -1.187, -0.105))
Weld.Part0 = PartToAttach0
Weld.Part1 = PartToAttach1
Forgot to mention, you need to parent your weld somewhere so the part will be attached.