Why does this not work?

It teleports the player without issues, but it doesn’t add the shovel to the player. No errors,
heres my script:

script.Parent.MouseClick:Connect(function(player)
	local character = player.Character
	local humanoidRootPart = character.HumanoidRootPart
	local prevCFrame = humanoidRootPart.CFrame

	local NewShovel = workspace.Shovelth.Shovel:Clone()

	humanoidRootPart.Anchored = true
	humanoidRootPart.CFrame = workspace.AddShovelPos.CFrame

	local motor6d = workspace.Shovelth["Right Arm"].Shovel:Clone()
	motor6d.Part0 = character["Right Arm"]
	NewShovel.Parent = character
	motor6d.Part1 = NewShovel
	motor6d.Parent = character["Right Arm"]
	motor6d.Name = "Shovel"
	wait(0.1)
	humanoidRootPart.Anchored = false
	humanoidRootPart.CFrame = prevCFrame

	game.ReplicatedStorage.Events.ChangeObjective:FireClient(player, "Dig under the Campfire.")
end)

I can’t use welds as an animation that’ll play eventually moves the shovel.

1 Like

uhhhh is this code inside of a localscript or serverscript?

1 Like

Possible causes:

  • Shovel is a model
  • Motor6D isn’t active or isn’t enabled
  • The already existing Motor6D isn’t deleted and is taking priority or disabling both Motor6Ds

The code is inside a serverscript

1 Like

Shovel is a union
Thrjrjrjrjrjextracharacters

Could be one of the other causes I listed then

Motor6d is enabled . I created it, made the animations and scripted it.

And what other existing motor6d?

Have you tried creating a new motor6D and naming it to “Shovel” then copying the C0 and C1 values?

If none works, try debugging. Go to workspace and see if something went wrong with the motor6d or print the cloned motor6d’s Part0, Part1, C0, C1 values.

Or go into servermode and zoom to the shovel union. Its C0 and C1 values could be messed up
Screenshot 2024-11-02 123443
Screenshot 2024-11-02 123528

I’ve tried to copy for another previous thing in the game but it errored (I forgot the error) it was something like you can’t set c0 and c1 values

1 Like

By using Instance.new?
For example:

local ToCopy = workspace.RandomJoint

local var = Instance.new("Motor6D")
var.C0 = ToCopy.C0
var.C1 = ToCopy.C1
var.Parent = workspace

(Also could you elaborate further if possible? So we could look into this issue much further if nothing seems to work?)

So, in my game one of the objectives is to get the shovel out of the shed and then dig up under the campfire. But I don’t want to use a tool nor welds, as in the animation for digging, it’ll move the shovel.

You forgot to add the position of NewShovel.

what? I didn’t. it teleports the player to where the shovel is at then adds it to the player. It positions them exactly where the shovel should be then teleports the player back.

Then why not just instance.new a Motor6D and name it to the joint which is gonna be needed for animating? Then copy the C0 and C1 then set the Part0 and Part1, then after that, parent it to where it needs to be.

Here’s a basic idea how :LoadAnimation() works

First, it would look for the path of the joint in which you used to animate in the animation editor.
Second, if a joint exists in that path and that object in that path is a motor6D it would proceed to animating

local JointToFind = "Shovel"

local Humanoid = workspace.Char.Humanoid

--[[ The proccess to getting the joint ]]--
-- We'll need to find JointToFind. And it was last seen in Char["Right Arm"]

print(Char["Right Arm"]:FindFirstChild(JointToFind))
--Right now its false.
--Let's add a joint in that path

local newjoint = Instance.new("Motor6D")
newjoint.Name = "Shovel"
newjoint.Parent = Char["Right Arm"]

--Now let's see if it can find it
print(Char["Right Arm"]:FindFirstChild(JointToFind))
-- Now it prints true! It will now proceed to animating that joint.
-- Even though it was created after, it will still get accepted as a joint

Third, it would grab the cframe data from the next keyframe and set the C0 and C1 values accordingly.

huh??

extracharacterssssssssss


it is supposed to look like this when attached to a player.

I’m dumb :man_facepalming::man_facepalming: it does show up it’s just that my game is force first person so u couldn’t see it.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.