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

How do you make this face the right way where the mouse is?

https://gyazo.com/67c16cbf5e55dd6f9534f07dc0f9c8be here's what i'm talking about

i'm bad at orientation i tried a few attempts but it just wont face the right way. please help me Here's my code!

script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr,mousehit)
SliceDamage = 25 + plr.leaderstats.Strength.Value
	script.Parent.Handle.Fire:Play()
	local Slice = game.ReplicatedStorage.Arrow:Clone()
	local BV = Instance.new("BodyVelocity")
	BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
	BV.P = Vector3.new(math.huge,math.huge,math.huge)
	BV.Velocity = mousehit.lookVector * 200
	BV.Parent = Slice

	Slice.Parent = game.Workspace
	Slice.CFrame = CFrame.new(root.Position,root.Position + Vector3.new(mousehit.lookVector.x,0,mousehit.lookVector.z))
	script.Parent.Handle.Reload:Play()
	
	Slice.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid")then
			if hit.Parent.Name ~= plr.Name then
				if CoolDown == false then
					CoolDown = true
					if hit.Parent.Humanoid.Health <= 0 then
						local creator = Instance.new("ObjectValue",hit.Parent.Humanoid)
						creator.Value = plr
						creator.Name = "creator"
						game:GetService("Debris"):AddItem(creator,0.3)
					end
					hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - SliceDamage
					wait(0.5)
					CoolDown = false
				end
			end
		end
	end)
	
	Debris:AddItem(Slice, 3)
end)

1 answer

Try using CFrame.Angles

So in line 12 when you set the CFrame, you could be like

Slice.CFrame = CFrame.new(root.Position,root.Position + Vector3.new(mousehit.lookVector.x,0,mousehit.lookVector.z))  * CFrame.Angles(0, 0, math.rad(90))

I do not know what math.rad is, all I know is that it has something to with radians (which I haven't learned about yet). Experiment with this.

math.rad(90) should turn something in a 90 degree angle. So if your arrow is facing backwards when you do this, try using math.rad(-90) or math.rad(270).

2 comments

0

i'll try

0

accept the answer if it worked

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