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

How can I fix the position of the orb?

Asked by 1 year ago

Hello!

As the title says, I am making an attack where an orb spawns on the right arm of the character which Is moved a bit In the Y-Axis (The orb goes down) and the user smashes the orb Into the ground

The problem Is that the position of the orb gets glitched

Script:

local Tool = script.Parent
local Debounce = false

Tool.Activated:Connect(function()
    if not Debounce then
        Debounce = true
        game:GetService("Chat"):Chat(Tool.Parent.Head,"Its time to wish you a very happy birthday Haha!",Enum.ChatColor.White)
        Tool.Parent.HumanoidRootPart.Anchored = true
        Tool.Parent.Voiceline:Play()
        Tool.Summon:Play()
        local SorrowBall = game:GetService("ReplicatedStorage").Stuff["Sorrow Ball"]:Clone()
        local Weld = Instance.new("WeldConstraint",SorrowBall)
        game:GetService("Debris"):AddItem(Weld,1.20)
        SorrowBall.Parent = game.Workspace
        SorrowBall.Position = Tool.Parent["Right Arm"].Position
        SorrowBall.Orientation = Tool.Parent["Right Arm"].Orientation
        SorrowBall.CFrame = CFrame.new(0,-3,0)
        SorrowBall.CanCollide = false
        SorrowBall.Anchored = false
        Weld.Part0 = SorrowBall
        Weld.Part1 = Tool.Parent["Right Arm"]
        local AnimationTrack = Tool.Parent.Humanoid:FindFirstChild("Animator"):LoadAnimation(Tool.Animation)
        AnimationTrack:Play()
        wait(1.20)
        SorrowBall.Anchored = true
        Tool.Explosion:Play()
        game:GetService("Debris"):AddItem(SorrowBall,3)
        wait(1)
        Tool.Parent.HumanoidRootPart.Anchored = false
        Debounce = false
    end
end)

1 answer

Log in to vote
0
Answered by
xXMadonXx 190
1 year ago
Edited 1 year ago

Edit: If you want to make the orb move from the arms position relative to world space do something like this:

sorrowBall.Position = arm.Position + Vector3.new(0,-3,0)

You are moving the Orb to the Position 0,-3,0 in workspace and not that amount from the arm.

To move the Orb relative to the arm and keep it straight do something like

--Replace Arm with the arm in your script
sorrowBall.CFrame = arm.CFrame * CFrame.new(Vector3.new(0,-3,0)) * arm.CFrame.Rotation

If you do not care that the Orb is upright, you can remove Arm.CFrame.Rotation

What this code (or math) basically does is get the CFrame position and rotation from the arm and add values to it.

If you want to add rotation relative to your Arm do (Example: 10° all ways)

sorrowBall.CFrame = arm.CFrame * CFrame.new(Vector3.new(0,-3,0)) * CFrame.Angles(Vector3.new(math.rad(10),math.rad(10),math.rad(10)))
0
If you are wondering: You probably want the first one. I just put the other 2 in because my Brain jumped there first as you are trying to use CFrames xXMadonXx 190 — 1y
Ad

Answer this question