Exoiryx
(Exoiryx)
November 2, 2022, 11:21am
#1
I need a bat to be spawned onto the players hand when they are loaded in but i can find out how to get the bat to be rotated by 90 degrees on the X axis
I’ve tried asking on multiple discord servers but no ones helping
here is my code:
game.ReplicatedStorage.BatAb.Start.OnServerEvent:Connect(function(Player)
print('awaaw')
local H = game.ServerStorage.Mace
H.Parent = Player.Character["Right Arm"]
H.PrimaryPart = H.Main
H.PrimaryPart.Orientation = Vector3.new(90,y,z) -- I believe my issue is here
local weld = Instance.new("Weld")
weld.Parent = H.PrimaryPart
weld.Part0 = H.PrimaryPart
weld.Part1 = Player.Character['Right Arm']
H.PrimaryPart.Position = H.Parent.Position
weld.C0 = CFrame.new(0, 0.2, 0)
print(H.Parent.Position)
end)
Thanks for reading
I believe the issue is you never defined the Y and Z values in the vector. So in order to do so it should look something like this
Vector3.new(90, H.PrimaryPart.Orientation.Y, H.PrimaryPart.Orientation.Z)
Exoiryx
(Exoiryx)
November 2, 2022, 11:27am
#3
is it supposed to be Vector.new or is it Vector3.new?
Vector3.new. Sorry that was a typo on my part
Exoiryx
(Exoiryx)
November 2, 2022, 11:31am
#5
hmm still no difference do you have any other method I could try to make it rotate?
some one was telling me to do something with the CFrames but they never really specified
Exoiryx
(Exoiryx)
November 2, 2022, 11:41am
#6
I found out how to rotate it but it doesn’t change the angle of all the parts inside the model
The only other method (at least to my knowledge) is to try just rotate without the use of cframe like this
H.PrimaryPart.Orientation = Vector3.new(90,H.Primarypart.Orientation.Y,H.PrimaryPart.Orientation.Z)
But it’s not as efficient but you never know, so it may be worth trying out.
Exoiryx
(Exoiryx)
November 2, 2022, 11:43am
#8
It rotated it but now we have another issue
do you know why the main part isn’t rotating with the others?
Odd. Is any of your parts anchored?
dthecoolest
(dthecoolest)
November 2, 2022, 11:44am
#10
Use rigid constraint instead, it is simpler as you can rotate the attachments instead and in real time.
Or you can use the attachment CFrame to position the weld
local attachment = Instance.new("Attachment")
attachment.Parent = Player.Character["Right Arm"]
attachment.CFrame --position using studio
--Or you can use orientation and Position if you prefer
attachment.Position = --something
attachment.Orientation = --something
weld.Part1 = Player.Character['Right Arm']
weld.C1 = attachment.CFrame --Edit C1 as Part 1 is the right arm same as attachment arm.
The issue with your code is the orientation doesn’t effect the weld positioning which is done via C0 and C1, also it disjoints and breaks the weld like in the image you sent.
Exoiryx
(Exoiryx)
November 2, 2022, 11:45am
#11
None of the parts are anchored
Exoiryx
(Exoiryx)
November 2, 2022, 11:48am
#12
I have got no idea how this works or where to put anything
dthecoolest
(dthecoolest)
November 2, 2022, 11:51am
#13
No worries it’s your first time learning of this,
Perhaps you should look at this other examples based on a similar problem,
Rigid constraint method:
I decided to use the Rigid Constraint you were talking about and that worked very well
for anyone curious this is what I did:
local RigidConstraint = Instance.new("RigidConstraint")
RigidConstraint.Parent = CharacterClone:FindFirstChild("Right Arm")
RigidConstraint.Attachment0 = CharacterClone:FindFirstChild("Right Arm").RightGripAttachment
local Attachment = Instance.new("Attachment")
Attachment.CFrame = ToolClone.Grip * CFrame.Angles(math.rad(90),0,0) --This offset is applied by default f…
Weld solution method:
I swear I tried that but I actually got that to work this time around.
so this is actually the true solution:
local RightGrip = Instance.new("Weld")
RightGrip.Name = "Right Grip"
RightGrip.Parent = CharacterClone:FindFirstChild("Right Arm")
RightGrip.Part0 = CharacterClone:FindFirstChild("Right Arm")
RightGrip.Part1 = ToolClone.Handle
RightGrip.C1 = ToolClone.Grip * CFrame.Angles(math.rad(90),0,0)
RightGrip.C0 = CharacterClone:FindFirstChild("Right Arm").RightGripAttachment.CFrame…
Exoiryx
(Exoiryx)
November 2, 2022, 11:56am
#14
is ToolClone the same as my H.PrimaryPart?
dthecoolest
(dthecoolest)
November 2, 2022, 12:01pm
#15
Why don’t you try it and run it in order to verify it is correct?
Exoiryx
(Exoiryx)
November 2, 2022, 12:02pm
#16
because i dont have RightGripAttachment either
dthecoolest
(dthecoolest)
November 2, 2022, 12:12pm
#17
Then you probably should create one. R15 has it by default but I see you are using R6.
Use a dummy rig, create an attachment inside the arm, then Position it to where you want the weapon to be.
After that you can recreate it in script using Instance.new(“Attachment”) and use it’s orientation and position properties.
Exoiryx
(Exoiryx)
November 2, 2022, 12:24pm
#18
Still not rotating the main part properly and I don’t fully understand this
and I cant find a more comprehensive guide because all the ones similar are using tools instead of a group
dthecoolest
(dthecoolest)
November 2, 2022, 12:32pm
#19
Have you checked this solution? It doesn’t use a tool but a model:
I call this one the no-code accessory method. It uses the underappreciated accessories and the amazing attachment setup already found in Humanoids. All you need to do is call AddAccessory on the knife after cloning it. As for welding, do it in Studio with WeldConstraints, don’t write code for it.
There’s of course many ways to make pseudotools, as in attaching models to arms instead of using tools. I’m a big fan of it and do it a lot. I’ll just be showing you the easy and quick way without much…
Also R6 should have attachments my model was also outdated:
Where are you getting your test dummies from? R6 characters have hand attachments added natively. You may not be working with an updated model. It’s best to reference an actual character that’s constructed in a live game rather than something generated or retrieved from another source.
See:
[image]
Don’t use StarterCharacter if you aren’t majorly changing the construct of a rig.
Exoiryx
(Exoiryx)
November 2, 2022, 12:37pm
#20
i don’t know man its getting too complex for me ill try tomorrow