I’ve encountered an issue with my Pets where-in they don’t seem to move after a reset and insertion of a new model:
My script works by: Inserting the Pet server side, setting Ownership to the Player and managing movement via the client.
So far, after testing I’ve come to realise the issue may be Client based - as without the ‘RenderStepped’ the Humanoid will move to the set Vector, however with it - It will not. Not even while true() works.
EDIT: - After messing around with it, and even wrapping the code in Spawn(functions()) and coroutine, I can confirm it still has not worked. I’ve attached the Model if anyone could take a look I would be grateful.Follow_.rbxm (111.5 KB)
Server script
local Pets = Instance.new("Folder", workspace)
Pets.Name = "Player_Followers"
local Main = script.Kangop:Clone()
game.Players.PlayerAdded:Connect(function(NewPlayer)
NewPlayer.CharacterAdded:Connect(function(NewCharacter)
local Model = Main:Clone()
Model.Parent = Pets
local Owner = Instance.new("ObjectValue", Model:WaitForChild("Follower"))
Owner.Name, Owner.Value = "Owner", game.Players:GetPlayerFromCharacter(NewCharacter)
NewCharacter:WaitForChild("Humanoid").HealthChanged:Connect(function(Health)
if Health == 0 then Model:Destroy() else end
end)
for _,Parts in pairs (Model:GetDescendants()) do
if Parts:IsA("BasePart") and Parts.Anchored == false then
Parts:SetNetworkOwner(game.Players:GetPlayerFromCharacter(NewCharacter))
else end
end
NewPlayer:WaitForChild("PlayerGui"):WaitForChild("Evolyt_Controls").Follow:FireClient(game.Players:GetPlayerFromCharacter(NewCharacter), Model)
end)
end)
Client script
local Main = script.Parent
local Player = game.Players.LocalPlayer
local Player_Followers = workspace:WaitForChild("Player_Followers")
function Animate_Model(Model)
spawn(function()
require(Model:WaitForChild("Animate")).Configure()
end)
end
for _,v in pairs (Player_Followers:GetChildren()) do
if v then
if v:IsA("Model") and v:FindFirstChild("Animate") ~= nil then
if v:WaitForChild("Follower").Owner.Value == Player then
else Animate_Model(v) end
else return end
else return end
end
Player_Followers.ChildAdded:Connect(function(NewChild)
if NewChild:IsA("Model") and NewChild:FindFirstChild("Animate") ~= nil then
Animate_Model(NewChild)
else return end
end)
Main:WaitForChild("Follow").OnClientEvent:Connect(function(Model)
local HumanoidRootPart = Player.Character:WaitForChild("HumanoidRootPart")
game:GetService("RunService").RenderStepped:Connect(function()
Model:WaitForChild("Follower"):MoveTo(Vector3.new(10, 10, 10))
end)
end)