Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I fix a welded model's orientation changing every time I call a function?

Asked by 3 years ago

I know what the problem is, I just don't know the solution and I've been looking for like an hour or so, so I figured since I've tried so much and can't find the solution it'd be better to ask directly for it.

What I'm trying to do is weld a shovel to the character's right hand, I have a shoveling animation all set up and the shovel is welded to the right hand. The issue is that the orientation changes every time.

I believe it's because of the player's idle animation moving the hand's orientation slightly making the shovel's orientation move too. Here's the code, tell me if there's an important piece of information missing, but I don't think there is.

(Also, the CFrame stuff is just things I tried, CFrames confuse me and it didn't work)

local pps = game:GetService("ProximityPromptService")
local pp = script.Parent.ProximityPrompt
local Shovel = game.Workspace.Tools.Shovel

pps.PromptTriggered:Connect(function(pp, plr)
    local character = plr.Character
    local humanoid = character.Humanoid
    local grass = script.Parent
    local track = humanoid:LoadAnimation(script.Parent.Dig)
    local newShovel = Shovel:Clone()
    local ShovelWeld = Instance.new("WeldConstraint")
    newShovel.Name = "NewShovel"
    newShovel.Handle.Position = character.RightHand.Position
    newShovel.Parent = character
    newShovel.Handle.CFrame = CFrame.new(newShovel.Handle.Position) * CFrame.fromEulerAnglesXYZ(math.rad(0 + character.RightHand.Orientation.x), math.rad(90 + character.RightHand.Orientation.y), math.rad(-180 + character.RightHand.Orientation.z))
    ShovelWeld.Parent = newShovel.Handle
    ShovelWeld.Part0 = character.RightHand
    ShovelWeld.Part1 = newShovel.Handle
    track:Play()
    track.Stopped:Wait()
    newShovel:Remove()
    ShovelWeld:Remove()
    wait(1)
end)

Thank you so much if you know the solution!!!

0
you should try using r6, this may not help but the animations are way less movements than r15 Xapelize 2658 — 3y
0
The problem with this is the digging animation is R15 and it looks really bad in R6. Hqsuperlabgames 41 — 3y

Answer this question