Hey everyone! So today I was working on my obby, and I was trying to make it so rats could move back and forth as a stage. If you touch them, they kill you. But whenever I try to make them move, they just sit there and do nothing, there are no errors, and everything should be working. The rat doesn’t have a humanoid part, but it has a torso so I made the primary part the torso. ALSO, the model isn’t anchored which nothing was anchored the last time I did this with another thing and it worked. Here is my script.
local NPC = game.Workspace.Rat
local p1 = game.Workspace.Travel1
local p2 = game.Workspace.Travel2
while true do
wait(1)
NPC.Humanoid:MoveTo(p1.Position)
wait(2)
NPC.Humanoid:MoveTo(p2.Position)
wait(3)
end
If you check while the game is running, does their health show as 0? That’s one possible cause.
This could also be a HipHeight issue. Some humanoids need their HipHeight adjusted before they can walk properly.
local default = TweenInfo.new(1,Enum.EasingStyle.Linear)
local TargetPos = Part2.CFrame
local goal = {}
goal.Position = TargetPos
local tween = TweenService:Create(Part to be tweened, default, goal)
tween:Play()
ok so this is what I did, but it says that Argument 3 missing, or nil… Not really sure what I could have done wrong here.
local TweenService = game:GetService("TweenService")
local NPC = game.Workspace.Rat
local p1 = game.Workspace.Travel1
local p2 = game.Workspace.Travel2
local info = TweenInfo.new(1.5,Enum.EasingStyle.Back,Enum.EasingDirection.Out)
local move = NPC:MoveTo(p1.Position)
local Move = NPC:MoveTo(p2.Position)
local tween = TweenService:Create(NPC,info,move)
local Tween = TweenService:Create(NPC,info,Move)
while true do
wait()
tween:Play()
wait(1.5)
Tween:Play()
wait()
end
That’s because both your move variables are function calls which are defined as the return value of MoveTo, which doesn’t return a value. You’re essentially passing nil here.
I think the point of raising TweenService was that you don’t use any of the Humanoid or Model methods at all and instead control your NPC’s movement solely by tweening them back and forth. Considering they’re just a simple obstacle, this would be much more performant as well over trying to use Humanoids (those are, on their own, quite expensive).
You should read the article on TweenService so you can get a better understanding of how to use it, analyse what you’re doing wrong and then make changes based off of that.
Thanks everyone for the help, I just gave up on it because I’m pretty confused (I’m not a fast learner) I just decided to make a simple stage instead of rats moving. Anyways, thanks for the help.