Help Tweening a Model on a Local Script

  1. What do you want to achieve? Keep it simple and clear!
    I am making a script to tween a models position to the players mouse, but I only want it to work on the client side.

  2. What is the issue?
    It is only tweeting the primary part even though the whole model is welded to the primary part.

  3. What solutions have you tried so far?
    Ive tried messing around with the welds and I have not had much luck.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

--This is a local script in the tool
local TS = game:GetService("TweenService")
local ToolFolder = game:WaitForChild("ReplicatedStorage"):WaitForChild("Tools")
local FTFolder = ToolFolder:WaitForChild("FakeTools")
local LPlayer = game.Players.LocalPlayer
local Mouse = LPlayer:GetMouse()
local MoveFunction = nil
local TInfo = TweenInfo.new(.2)


script.Parent.Equipped:Connect(function()
	local FakeModel = FTFolder:WaitForChild("FakeBarricadePW"):Clone()
	FakeModel.Parent = game.Workspace
	local PartToMove = FakeModel:WaitForChild("Main")
	MoveFunction = Mouse.Move:Connect(function()
		local Filter = LPlayer.Character:GetDescendants()
		local Param = RaycastParams.new()
		Param.FilterType = Enum.RaycastFilterType.Exclude
		Param.FilterDescendantsInstances = Filter
		local raycastResult = workspace:Raycast(Mouse.UnitRay.Origin, Mouse.UnitRay.Direction * 250,Param)
		if raycastResult then
			local raycastHit = raycastResult.Instance
			if raycastHit then
				local ExactPos = raycastResult.Position
				local goal = {}
				goal.Position = ExactPos
				local Tween = TS:Create(PartToMove,TInfo,goal)
				Tween:Play()
			end
		end
	end)
end)

Is there some way to go about with this?

3 Likes

After experimenting more, I should have been doing Goal.CFrame instead of Goal.Position. If the part’s CFrame never changes then the other parts will not move with it.

2 Likes

Some explanation (might not be correct)

Model’s don’t actually have a separate position like parts do, doing Goal.Position doesn’t grab the objects inside of the Model, but rather just grabs the Model object itself and essentially just moves that specifically, just like if Part A was parented under Part B, moving Part B wouldn’t actually move Part A, it would only move Part B

However, doing Goal.CFrame.Position or simply just Goal.CFrame will collect all the objects inside the group itself, and will take the model and will move it to whatever new value you give it.

There is also things like :MoveTo(), :SetPrimaryPartCFrame(), and PrimaryPart which I think if I’m correct could also be another way of solving this, but you usually see this with like Tweening and stuff like that.

Again could be wrong but this is sort of just my way of thinking about it.
Yes I know this post was already solved.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.