the folders cvalled Pets
- User
the folders cvalled Pets
Assistant
Here's the corrected script that looks for a folder called "Pets" in ReplicatedStorage:
-- Server Script (put this in ServerScriptService) local ReplicatedStorage = game:GetService("ReplicatedStorage") local Workspace = game:GetService("Workspace") local function onDropButtonClicked(player) -- Get the Spawn part local spawnPart = Workspace:FindFirstChild("Spawn") if not spawnPart then warn("Spawn part not found in Workspace!") return end -- Get the Pets folder local petFolder = ReplicatedStorage:FindFirstChild("Pets") if not petFolder then warn("Pets folder not found in ReplicatedStorage!") return end -- Get all models in the Pets folder local petModels = petFolder:GetChildren() if #petModels == 0 then warn("No models found in the Pets folder!") return end -- Select a random model local randomIndex = math.random(1, #petModels) local randomModel = petModels[randomIndex]:Clone() -- Position the model at the spawn part randomModel:SetPrimaryPartCFrame(spawnPart.CFrame) -- Parent the model to workspace randomModel.Parent = Workspace -- Optional: Clean up after some time -- game:GetService("Debris"):AddItem(randomModel, 60) -- Removes after 60 seconds end -- Connect the button click event game:GetService("Players").PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) local button = character:FindFirstChild("DropButton") if button then button.Activated:Connect(function() onDropButtonClicked(player) end) end end) end)Would you like me to explain or break down this code?
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.