Hello, im trying to make a cannon that kills people automatically but it rotates to the opposite of the torso's position, how can i get the opposite of it, like if its pointing to the south, point to the north This is the code im using :
local debounce = false
script.Parent.area.Touched:Connect(function(c)
if script.Parent.Auto.Value then -- auto is a bool value
if c then
if c.Parent then
if c.Parent ~= workspace then
if c.Parent:FindFirstChildOfClass("Humanoid") or game:GetService("Players"):GetPlayerFromCharacter(c.Parent) then
if not debounce then
local torso
if c.Parent:FindFirstChild("Torso") then
torso = c.Parent:FindFirstChild("Torso")
elseif c.Parent:FindFirstChild("UpperTorso") then
torso = c.Parent:FindFirstChild("UpperTorso")
end
if torso then
debounce = true
local goal = CFrame.new(script.Parent.Cannon.PrimaryPart.Position,Vector3.new(torso.Position.X,script.Parent.Cannon.PrimaryPart.Position.Y,torso.Position.Z))
for i = 0,100,0.2 do
if script.Parent.Cannon.PrimaryPart.CFrame == goal then
break
end
local posTo = script.Parent.Cannon.PrimaryPart.CFrame:Lerp(goal,i/100)
script.Parent.Cannon:SetPrimaryPartCFrame(posTo)
wait(0.01)
end
script.Parent.Cannon.Model.pew.Transparency = 0
wait(1)
script.Parent.Cannon.Model.pew.Transparency =1
wait(2)
debounce = false
end
end
end
end
end
end
end
end)

2 comments
The opposite of a vector v is -v, it's literally that easy.
Not if it's a position vector. -_-