So I'm trying to make a grenade that you hold in your hand without using the tool. Everything works, except for when you hold it. It stays in the same position like I never added the extra Vector3. Could someone help? Thanks!
Here's the script:
local Grenade = game.ServerStorage.Grenade:Clone() local Motor = Instance.new("Motor6D") Grenade.Parent = game.Workspace Grenade.Position = plr.Character["Right Arm"].Position + Vector3.new(0, 50, 0) -- This is where I'm having problems. print(Grenade.Position) Motor.Parent = Grenade Motor.Part0 = Grenade Motor.Part1 = plr.Character["Right Arm"]
EDIT: The position does change when I take out the + Vector3 and add it in but it still stays in the same position. Why??
I gave it a shot myself and came up with this, which seems to work. So as stated by the Wiki, C0
is how the offset point is attached to Part0
which is the player's right (lower) arm in this case, and C1
is subtracted from C0
to create the offset point for Part
, the grenade.
In this example, the offset point for the grenade is just a little under the hand.
local RBX_P = game:GetService("Players"); local RBX_W = game:GetService("Workspace"); local grenadeModel = RBX_W:WaitForChild("Grenade"); RBX_P.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) wait(2.5); local rightArm = character:WaitForChild("RightLowerArm"); local grenade = grenadeModel:Clone(); grenade.Parent = character; local motor = Instance.new("Motor6D"); motor.Part0 = rightArm; motor.Part1 = grenade motor.C0 = rightArm.CFrame; motor.C1 = motor.C0 * CFrame.new(0, 1.1, 0.25); motor.Parent = rightArm end) end)