So the title pretty much sums it up. I’m trying to make a shooting mechanism and I shoot model towards a different player. The problem is that it rotates to the players humanoid root part orientation too. Here is the code
local model = script.Model:Clone()
model:SetPrimaryPartCFrame(CFrame.new(player.Character.HumanoidRootPart.Position, closestPlayer.Character.HumanoidRootPart.Position))
model.Parent = player.Character
local CFrameValue = Instance.new("CFrameValue")
CFrameValue.Value = model:GetPrimaryPartCFrame()
CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
model:SetPrimaryPartCFrame(CFrameValue.Value)
end)
local tweeninfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.In)
local CF = CFrame.new(closestPlayer.Character.HumanoidRootPart.Position)
local tween = TweenService:Create(CFrameValue, tweeninfo, {Value = CF})
tween:Play()
tween.Completed:Connect(function()
CFrameValue:Destroy()
end)
Does anyone know what’s going on here? I searched it up and by just giving a Vector3 it shouldn’t give it any rotation.
That’s odd, but again, if I may ask, why do you need to use CFrame? CFrames typically hold a Position and a Rotation again, if you’re doing that to move the model, can’t you just do this?
CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
local cframe = CFrameValue.Value
model:MoveTo(cframe.p)
end)
So it moves the model with the Position of the CFrame only?
This kind of works but I get this up and down motion with the tween
It looks like as if can collide is on for the parts but it’s not. I’ve set can collide to off
EDIT: After some reading I found this for the :MoveTo function
If there are any obstructions where the model is to be moved to, such as Terrain or other BasePart s, then the model will be moved up in the Y direction until there is nothing in the way. If this behavior is not desired, Model:SetPrimaryPartCFrame should be used instead.
First off, remove that. You are ruining the purpose of a tween.
Second,
Let’s fix this.
local pos = closestPlayer.Character.HumanoidRootPart.Position
local pos2 = mainplayerhere.Character.HumanoidRootPart.Position
local CF = CFrame.lookAt(pos2,pos) -- Pos2 being the "from", pos being the "to".
This would create a thing where it would be pointing at the player while it is going towards them, and then when getting close it would turn sideways or like “flat”.
You could have just made it so the mouse can be going to the player from like 3 - 7 studs away, and when the mouse makes contact it makes a effect that it’s disappearing, and the player would die in-game too.