This script is not working… don’t know why? I tried putting prints everywhere and they all printed. No errors.
Serverscript inside a part I’m using to script pets.
local pet = script.Parent
function givePet (player)
if player then
repeat wait() until player.Character
local character = player.Character
if character then
local focusPart = character.UpperTorso
local newPet = pet:Clone ()
newPet.Parent = character
local bodyPos = Instance.new("BodyPosition", newPet)
bodyPos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
local bodyGyro = Instance.new("BodyGyro", newPet)
bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
while wait() do
bodyPos.Position = focusPart.Position + Vector3.new(2, 2, 3)
bodyGyro.CFrame = focusPart.CFrame
end
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
givePet(player)
end)
end)
Hey. Thanks for your input but that’s not what I am looking for. I added several little checks to make sure the character existed because the script was not functioning. When the pet wasn’t going to the player I added the repeat wait() until player.Character.
Instead of the longer version you had. The reason I had multiple checks to see if the player and character existed was to make sure that the player and the character existed. Like I said, the script wasn’t functioning so trial, error and testing is the only way to effectively debug.