CanCollide is not a valid member of Model "Dog" script is
local runService = game:GetService("RunService")
local pet = game.ReplicatedStorage:WaitForChild("Dog") local offset = CFrame.new(2, 2, 2) -- relative location
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) local humanoidRootPart = character:WaitForChild("HumanoidRootPart") local humanoid = character:WaitForChild("Humanoid")
local newPet = pet:Clone() -- New pet newPet.CanCollide = false newPet.CFrame = humanoidRootPart.CFrame * offset
pls help
CanCollide
and CFrame
are not properties of Models
, they are properties of BaseParts
.
In order to get this working, first, you need to set the PrimaryPart
of the dog model. This can be done through the properties window. Then, set the CFrame
of the primary part and set CanCollide
of all things within the model. Also, the RunService
is not being used here.
local runService = game:GetService("RunService") local pet = game.ReplicatedStorage:WaitForChild("Dog") local offset = CFrame.new(2, 2, 2) -- relative location game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) local humanoidRootPart = character:WaitForChild("HumanoidRootPart") local humanoid = character:WaitForChild("Humanoid") runService.RenderStepped:Connect(function() local newPet = pet:Clone() -- New pet for i, v in pairs(newPet:GetChildren()) do if v:IsA("BasePart") then v.CanCollide = false end end newPet:PivotTo(humanoidRootPart.CFrame * offset) end) end) end)
Here's the script without RunService
in use.
local runService = game:GetService("RunService") local pet = game.ReplicatedStorage:WaitForChild("Dog") local offset = CFrame.new(2, 2, 2) -- relative location game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) local humanoidRootPart = character:WaitForChild("HumanoidRootPart") local humanoid = character:WaitForChild("Humanoid") local newPet = pet:Clone() -- New pet for i, v in pairs(newPet:GetChildren()) do if v:IsA("BasePart") then v.CanCollide = false end end newPet:PivotTo(humanoidRootPart.CFrame * offset) end) end)
Notes:
If :PivotTo
is giving issues, use :SetPrimaryPartCFrame
instead.