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

Hand always moving In the same direction, and not where the player Is facing (?)

Asked by 2 years ago

Hello developers!

As the title says, I am making a move for a morph (Which the move Is a tool) that summons a hand that currently does nothing besides moving to where the player Is facing, but on contact, grabs the victim and slams them Into the ground, the problem Is that when using the ability the hand always go In the same direction

Script:

local Tool = script.Parent
local Troll = Tool.Parent
local SANS = Troll.SANS
local Debounce = false

Tool.Activated:Connect(function(player,mousePos)
    if not Debounce then
        Debounce = true
        Troll.HumanoidRootPart.Anchored = true
        local SANSAnimation = Troll.Humanoid:FindFirstChild("Animator"):LoadAnimation(SANS)
        SANSAnimation:Play()
        wait(0.30)
        local Hand = Instance.new("Part",game.Workspace)
        local Mesh = Instance.new("SpecialMesh",Hand)
        Hand.Position = Troll.Torso.Position
        Hand.Orientation = Troll.Torso.Orientation
        Hand.Size = Vector3.new(4, 4, 2)
        Hand.Anchored = true
        Hand.CanCollide = false
        Hand.CastShadow = false
        Hand.Rotation = Vector3.new(0,0,-180)
        Mesh.MeshId = "http://www.roblox.com/asset/?id=32054761"
        for i=0, 20 do
            Hand.CFrame = Hand.CFrame + (Hand.CFrame.LookVector * 1)
            wait()
        end
        game:GetService("Debris"):AddItem(Hand,0)
        wait(2)
        Troll.HumanoidRootPart.Anchored = false
        Debounce = false
    end
end)

1 answer

Log in to vote
0
Answered by 2 years ago

the code here always sets the hand's rotation to (0, 0, -180). setting the rotation is relative to the world so it's always going to face negative Z ("north") but upside down. you need to

  1. flip it upside down (if that's what you're trying to do)
  2. get the hand facing the same direction as the player (keep in mind that the player's camera's orientation/position can only be accessed clientside, and you'll need a localscript to pass it to the server if that's where you want the hand to face)
0
Im trying to not make the hand be upside down, but thanks (Or maybe clarify me If I misunderstand imnotaguest1121 362 — 2y
0
if this solved your problem then could you choose mine as the answer? TheDude646 72 — 2y
0
Yeah sure imnotaguest1121 362 — 2y
0
ty TheDude646 72 — 2y
Ad

Answer this question