Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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 :)

This discussion is preserved as it was. New answers, comments, and votes are closed.