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

I made a attack but when the attack(Union) is spawned its backwards. How do I rotate it?

Asked by 7 years ago
Edited 7 years ago

ONE thing I dont understand is when I summon this Union its backwards. How can I made it the way I want? I tried Vector3 but that only works when I am at a certain angle

https://gyazo.com/61fa539ea9dc259621e8d842d020bd44


UIS = game:GetService("UserInputService") Player = game.Players.LocalPlayer UIS.InputBegan:connect(function(Input) if Input.KeyCode == Enum.KeyCode.Y then game:GetService("Chat"):Chat(Player.Character.Head, "Rankyaku!", "Red") local Ball = script.Slash:Clone() Ball.Anchored = true Ball.Parent = workspace Ball.CanCollide = false Ball.CFrame = Player.Character.Head.CFrame * CFrame.new(0,1,-8) local Direction = Instance.new("BodyVelocity", Ball) Direction.maxForce = Vector3.new(math.huge,math.huge,math.huge,math.huge) Direction.velocity = Player.Character.Head.CFrame.lookVector*35 Ball.Anchored = false game.Debris:AddItem(Ball, 5) end end)

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

You can use CFrame.Angles to rotate your object.

Note: CFrame.Angles takes in radians, not studs. Use the math.rad function to convert.

UIS = game:GetService("UserInputService")

Player = game.Players.LocalPlayer

UIS.InputBegan:connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.Y then
        game:GetService("Chat"):Chat(Player.Character.Head, "Rankyaku!", "Red")
        local Ball = script.Slash:Clone()
        Ball.Anchored = true
        Ball.Parent = workspace
        Ball.CanCollide = false
        Ball.CFrame = Player.Character.Head.CFrame 
                    * CFrame.new(0,1,-8) 
                    * CFrame.Angles(0,math.rad(90),0)
        local Direction = Instance.new("BodyVelocity", Ball)
        Direction.maxForce = Vector3.new(math.huge,math.huge,math.huge,math.huge)
        Direction.velocity = Player.Character.Head.CFrame.lookVector*35 
        Ball.Anchored = false
        game.Debris:AddItem(Ball, 5)
    end
end)

If it is still not rotated correctly, mess around with the numbers :)

Ad

Answer this question