I was trying to make a Pets system for my game, and for some reason it keeps throwing the error "Position is not a valid member of Model" It shows that the error is caused in this function:
repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character function MovePet(pet, mode) local character = game.Players.LocalPlayer.Character local rpet = workspace:FindFirstChild(pet) local rmode = mode local inc = 0.7 if mode == "Normal" then local base = game.Players.LocalPlayer.Character:FindFirstChild("Left Leg") local dir = CFrame.new(rpet.Position, base.Position).lookVector print(dir) for i=0,10,2 do rpet.CFrame = rpet.CFrame + (dir * inc) wait(0.05) end elseif mode == "Float" then local base = character["Head"] end end while wait() do MovePet(game.Players.LocalPlayer.Name, "Normal") end
On this line,
local dir = CFrame.new(rpet.Position, base.Positiong.lookVector
I have this in a local script, and in-between the while wait loop and the function the pet is created with this code;
game.Players.PlayerAdded:connect(function(p) if p then local ppet = Instance.new("Part", game.Workspace) ppet.Size = Vector3.new(1,1,1) ppet.Color = BrickColor.new(math.random(1,255)/255, math.random(1,255)/255, math.random(1,255)/255) ppet.Material = "Neon" ppet.CFrame = p.Character["Left Leg"].CFrame ppet.Name = game.Players.LocalPlayer.Name ppet.CanCollide = false end end)
I tried doing character["Left Leg"], character:FindFirstChild("Left Leg"), game.Players.LocalPlayer.Character["Left Leg"] and also game.Players.LocalPlayer.Character:FindFirstChild("Left Leg")
So pet is a model, you need to do pet.[Part]. There isn't a position property in a model.
If you want the whole model to move, move it by cframe.
you can use PrimaryPartCFrame