pet models arnt spawing
- User
pet models arnt spawing
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
pet models arnt spawing
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Let's debug this step by step. Here's an updated script with detailed debugging information to help us figure out what's going wrong:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")
local Players = game:GetService("Players")
-- Function to spawn a random pet model at the Spawn part
local function spawnRandomPet()
print("=== SPAWN FUNCTION CALLED ===")
local spawnPart = Workspace:FindFirstChild("Spawn")
if not spawnPart then
warn("❌ Spawn part not found in Workspace!")
return
else
print("✅ Found Spawn part at position:", spawnPart.Position)
end
local petsFolder = ReplicatedStorage:FindFirstChild("Pets")
if not petsFolder then
warn("❌ Pets folder not found in ReplicatedStorage!")
return
else
print("✅ Found Pets folder")
end
local petModels = petsFolder:GetChildren()
print("📦 Number of items in Pets folder:", #petModels)
if #petModels == 0 then
warn("❌ No models found in Pets folder!")
return
end
-- Print all items in the folder
for i, model in ipairs(petModels) do
print("Pet", i, ":", model.Name, "- Type:", model.ClassName)
end
local randomIndex = math.random(1, #petModels)
local selectedPet = petModels[randomIndex]
print("🎲 Selected random pet:", selectedPet.Name)
local randomPet = selectedPet:Clone()
print("📋 Cloned pet successfully")
-- Try different positioning methods
if randomPet:IsA("Model") then
print("🏗️ Pet is a Model, trying to position...")
if randomPet.PrimaryPart then
print("✅ Model has PrimaryPart:", randomPet.PrimaryPart.Name)
randomPet:SetPrimaryPartCFrame(spawnPart.CFrame + Vector3.new(0, 5, 0))
else
print("⚠️ Model has no PrimaryPart, trying to find one...")
local foundPart = nil
for _, part in ipairs(randomPet:GetChildren()) do
if part:IsA("BasePart") then
foundPart = part
randomPet.PrimaryPart = part
print("✅ Set PrimaryPart to:", part.Name)
break
end
end
if foundPart then
randomPet:SetPrimaryPartCFrame(spawnPart.CFrame + Vector3.new(0, 5, 0))
else
print("❌ No BasePart found in model!")
-- Try positioning the first part manually
for _, part in ipairs(randomPet:GetChildren()) do
if part:IsA("BasePart") then
part.CFrame = spawnPart.CFrame + Vector3.new(0, 5, 0)
break
end
end
end
end
else
print("⚠️ Pet is not a Model, it's a:", randomPet.ClassName)
if randomPet:IsA("BasePart") then
randomPet.CFrame = spawnPart.CFrame + Vector3.new(0, 5, 0)
end
end
randomPet.Parent = Workspace
print("✅ Pet spawned in Workspace!")
print("=== SPAWN FUNCTION COMPLETE ===")
end
-- Listen for players joining
Players.PlayerAdded:Connect(function(player)
print("🔌 Player joined:", player.Name)
-- Wait for the PlayerGui to be ready
local playerGui = player:WaitForChild("PlayerGui", 10)
if not playerGui then
warn("❌ PlayerGui not found for player:", player.Name)
return
end
print("✅ Found PlayerGui for:", player.Name)
-- Find the Main ScreenGui inside PlayerGui
local mainScreen = playerGui:WaitForChild("Main", 10)
if not mainScreen then
warn("❌ Main ScreenGui not found for player:", player.Name)
print("Available GUIs in PlayerGui:")
for _, gui in ipairs(playerGui:GetChildren()) do
print(" -", gui.Name, "(" .. gui.ClassName .. ")")
end
return
end
print("✅ Found Main ScreenGui for:", player.Name)
-- Find the DropFrame inside Main
local dropFrame = mainScreen:WaitForChild("DropFrame", 10)
if not dropFrame then
warn("❌ DropFrame not found in Main ScreenGui for player:", player.Name)
print("Available items in Main:")
for _, item in ipairs(mainScreen:GetChildren()) do
print(" -", item.Name, "(" .. item.ClassName .. ")")
end
return
end
print("✅ Found DropFrame for:", player.Name)
-- Find the DropButton inside DropFrame
local dropButton = dropFrame:WaitForChild("DropButton", 10)
if not dropButton then
warn("❌ DropButton not found in DropFrame for player:", player.Name)
print("Available items in DropFrame:")
for _, item in ipairs(dropFrame:GetChildren()) do
print(" -", item.Name, "(" .. item.ClassName .. ")")
end
return
end
if not dropButton:IsA("TextButton") then
warn("❌ DropButton is not a TextButton, it's a:", dropButton.ClassName)
return
end
print("✅ Found DropButton for:", player.Name)
-- Connect the button click event
dropButton.Activated:Connect(function()
print("🖱️ DropButton clicked by:", player.Name)
spawnRandomPet()
end)
print("✅ Button connected for:", player.Name)
end)
print("🚀 Pet spawning script loaded!")
Run this script and then:
The debug messages will tell us exactly where the problem is:
Share the Output messages with me and I'll help you fix the specific issue!