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

[Solved] How to make a part face a certain mouse point?

Here is a part of my script:

local par = script.Parent
local skill = 0
par.RemoteEvent.OnServerEvent:Connect(function(player, pos, tar)
	local ani = par.Parent.Humanoid:LoadAnimation(script.Slash)
	local ani2 = par.Parent.Humanoid:LoadAnimation(script.Raise)
	par.Damage.Script.Disabled = false
	if skill <= 4 then
		ani:Play()
		wait(1)
		ani:Stop()
		skill = skill + 1
	elseif skill == 5 then
		ani2:Play()
		local new = game.ServerStorage.Spear:Clone()
		new.Parent = par
		script.Parent.Spear.Transparency = 1
		local velocity = Instance.new("BodyVelocity")
		local direction = pos - par.Spear.Position
		velocity.Parent = new
		new.CFrame = CFrame.new(par.Spear.Position, pos)
		velocity.Velocity = (direction).Unit*150
		velocity.MaxForce = Vector3.new(10000,10000,10000)
		wait(1)
		new:Destroy()
		par.Spear.Transparency = 0.6
		skill = 0
	end	
	par.Damage.Script.Disabled = true
end)

So this is a script in my tool. The mouse.hit.position is sent from my local script. So basically, when I activates my tool, it will impale but when it is activated for the 6th time, the player will throw the spear. My spear in the ServerStorage and it is an union. How do I make the top point of my spear face the mouse.hit.Position?

I think it works right but probably the top surface of the part is in a different side. If so, how do you change the top surface to the spear tip?

2 comments

0

multiply it by cframe.angles

0

for line 22 just put math.huge for every high number if you want the numbers to be as high a possible

1 answer

Sorry, I've found the answer. So the left side of my spear was actually the top surface, it was looking at the mouse.hit.position correctly. I added this after the CFrame.new:

*CFrame.Angles(0,math.rad(270),math.rad(90))

Thank you HappyTimIsHim

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