How can I move a model via TranslateBy() w/ local script?

I’m creating a model via local script for a client. And I need to move this model to create a small animation. I want to do this code:

X=script.Parent

while true do
	X:TranslateBy(Vector3.new(0, 0, -3)) 
	wait (0.01) 
end 

But this doesn’t work unless it’s a server script, and the server script wont run if it’s created on the client. How can I achieve what I need to do?

Use the normal script, and set it’s RunContext to client.

1 Like
local Part = script.Parent

while true do
      Part:PivotTo(CFrame.new(Vector3.new(0,0,-3))
      wait(0.01)
end

also have you setted your primary part of the model?

game:GetService("RunService").Heartbeat:Connect(function()
    local pos = script.Parent:GetPivot()
    script.Parent:PivotTo(CFrame.new(pos.X, pos.Y, pos.Z - 3)
end)

Setting RunContext just changes the script to a local script? Which I’ve already tried.

But it lets it run when its a descendant of workspace, which local scripts do not. Judging by your code, it looks like that’s the case.

Okay ty
//////////////////////////////////

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