I made a script, and it had an error, someone on SH helped me, but now I realized that the front of the block, is not the front of the tool! Can I change the lookVector (subtract or add 90 degrees to it)? Here is my script
wait(1) script.Parent.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() -- local animation = script.Slash -- local plyr = script.Parent.Parent.Name -- local char = workspace:FindFirstChild(plyr) -- local anim = char.Humanoid:LoadAnimation(animation) -- anim:Play() local bullet = Instance.new("Part") bullet.FormFactor = "Custom" bullet.Size = Vector3.new(0.5,0.2,0.2) bullet.BrickColor = BrickColor.new("Toothpaste") bullet.BackSurface = "SmoothNoOutlines" bullet.BottomSurface = "SmoothNoOutlines" bullet.FrontSurface = "SmoothNoOutlines" bullet.LeftSurface = "SmoothNoOutlines" bullet.RightSurface = "SmoothNoOutlines" bullet.Velocity = script.Parent.Part1.CFrame.lookVector * 100 --this part bullet.TopSurface = "SmoothNoOutlines" bullet.Parent = workspace bullet.Position = script.Parent.Handle.Position bullet.Transparency = 0 bullet.CanCollide = true --local speed = script.Speed:clone() --speed.Parent = bullet local damage = script.DamageScript:clone() damage.Parent = bullet print("HALLAAA") end) end)
Please help!!! Thank you!!!
You cannot 'change' lookVector
itself, because it's read-only. But you can do some math to get the direction of other faces. lookVector
is the direction of the Part's FrontFace, so using this we can get the other faces pretty simply;
--Forward part.CFrame.lookVector --Backward (negative or 'opposite' of lookVector) -part.CFrame.lookVector --Left (gets the lookVector of a CFrame rotated 90 degrees to the left) (part.CFrame * CFrame.Angles(0, math.rad(90), 0)).lookVector --Right (same as left, but negative. thus the opposite of left, which is right.) -(part.CFrame * CFrame.Angles(0, math.rad(90), 0)).lookVector
partToRotate.CFrame = partToRotate.CFrame * CFrame.Angles(0, math.rad(90), 0) -- the y axis rotates the front of the part a certain ammount. Change 90 to -90 if it isnt the right direction.