Hello!, i was following a tutorial from alvin blox about how to equipp pets but it wont work. I get 0 errors and i cant find anythign wrong with the code.

Im so sorry i forgot to tell teh problem, its supposed to change the text to equipped and equipp the pet but it wont do any of that.

I posted the whole code incase anyone would need more info, the code for equipping is at line 36

Here is the link to the vid

here is my code:

local tweenservice = game:GetService("TweenService")

local camera = game.Workspace.Camera
local studio = game.Workspace.HatchStudio
local template = script:WaitForChild("Template")
local scrollingFrame = script.Parent:WaitForChild("Pets"):WaitForChild("ScrollingFrame")

local button buttonConnections = {}

local function setTemplateEquipped(template)
	
	for i, v in pairs(scrollingFrame:GetChildren()) do
		if v:FindFirstChild("Equipped") then
			v.Equipped.Text = "UNEQUIPPED"
			v.Equipped.TextColor3 = Color3.fromRGB(207, 0, 0)
		end
	end
	
	template.Equipped.Text = "EQUIPPED"
	template.Equipped.TextColor3 = Color3.fromRGB(12, 191, 0)
end

local function addToFrame(pet)
	local newTemplate = template:Clone()
	newTemplate.Name = pet.Name
	newTemplate.PetName.Text = pet.Name
	newTemplate.Parent = scrollingFrame
	
	local newPet = pet:Clone()
	newPet.Parent = newTemplate.ViewportFrame
	
	local camera = Instance.new("Camera")
	camera.CFrame = CFrame.new(newPet.PrimaryPart.Position + (newPet.PrimaryPart.CFrame.lookVector * 3),newPet.PrimaryPart.Position)
	camera.Parent = newTemplate.ViewportFrame
	
	newTemplate.ViewportFrame.CurrentCamera = camera --------------------- HERE IS THE CODE
	
	buttonConnections[#buttonConnections+1] = newTemplate.MouseButton1Click:Connect(function()
		if newTemplate.Equipped.Text == "EQUIPPED"	then
			-- We know taht as its already equipped they want to unequipp it
			game.ReplicatedStorage.UnequipPet:FireServer()
			newTemplate.Equipped.Text = "UNEQUIPPED"
			newTemplate.Equipped.TextColor3 = Color3.fromRGB(207, 0, 0)
		else
			-- We know taht its already unequipped and now they want to equipp it
			game.ReplicatedStorage.EquipPet:FireServer(pet.Name)
			setTemplateEquipped(newTemplate)
		end
	end)
end

game.ReplicatedStorage.HatchEgg.OnClientEvent:Connect(function(pet)
	addToFrame(pet)
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = studio.CamPart.CFrame
	
	wait(1.5)
	
	for i = 1, 50, 1 do
		studio.Egg.Size = studio.Egg.Size + Vector3.new(0.1,0.1,0.1)
		wait(0.01)
	end
	
	-- By now the egg will be huge
	
	local explosion = Instance.new("Explosion")
	explosion.BlastRadius = 10
	explosion.BlastPressure = 0
	explosion.Position = studio.Egg.Position
	explosion.ExplosionType = Enum.ExplosionType.NoCraters
	explosion.DestroyJointRadiusPercent = 0
	
	explosion.Parent = studio.Egg
	
	studio.Egg.Transparency = 1
	
	local petClone = pet:Clone()
	
	for i, v in pairs(petClone:GetChildren()) do
		if v:IsA("BasePart") then
			v.Anchored = true
		end
	end
-- ################THIS IS FOR ACTIAVTING THE CONFETTI####################	
	for i, v in pairs(studio.confetti:GetChildren()) do
		if v:IsA("ParticleEmitter") then
			v.Enabled = true
		end
	end
	
	-- ################THIS IS FOR ACTIAVTING THE CONFETTI####################
	
	petClone:SetPrimaryPartCFrame(CFrame.new(studio.Egg.Position,studio.CamPart.Position))
	petClone.Parent = studio
	
	local tweenInfo = TweenInfo.new(
		2, -- time
		Enum.EasingStyle.Bounce,  -- style
		Enum.EasingDirection.Out,  -- direction
		0, -- repeat count
		false, -- repeat
		0  -- delay time
	)
	
	local tween = tweenservice:Create(camera, tweenInfo, {CFrame = CFrame.new(petClone.PrimaryPart.Position + (petClone.PrimaryPart.CFrame.lookVector * 5) + Vector3.new(0,0.75,0),petClone.PrimaryPart.Position)})
	
	tween:Play()
	
	wait(5)
	
	-- yes
	
	for i, v in pairs(studio.confetti:GetChildren()) do
		if v:IsA("ParticleEmitter") then
			v.Enabled = false
		end
	end

	-- yes
	
	camera.CameraType = Enum.CameraType.Custom
	studio.Egg.Transparency = 0
	studio.Egg.Size = Vector3.new(4.5, 5.4, 4.5)
	petClone:Destroy()
	
end)

*Code that is for the equipp is from 36 (where the comment "--HERE IS TEH CODE" is) Any help would be appriciated!

3 comments

2

If you're going to give us over a hundred lines of code, you need to be more descriptive than "it didn't work." What doesn't work? What have you tried? What should happen? What happens instead?

0

This is a request. I suggest you use the magical function called PRINT before calling it out to us.

0

Edited, sorry for any confusion