so I was trying to add a hatch system like pet simulator X and I am little confused about how to make the egg mesh appear as an gui
like I can make the tween or CFrame but how do I make The egg in workspace appear in ViewportFrame?(and for pets of course)?
I really Checked 6 different post’s and watched nearly 5 videos of people making hatch system but I guess I am kinda bad scripter…Dude times like that makes my motivation 0
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
here is the code if you need ıdk if you do or not
local Workspace= game:GetService("Workspace")
local ReplicatedStorage= game:GetService("ReplicatedStorage")
local Players= game:GetService("Players")
local BuyEgg= ReplicatedStorage.Remotes.Shop.BuyEgg
local PetHatched= ReplicatedStorage.Remotes.Shop.PetHatched
local Player = Players.LocalPlayer
local EggsFolder = Workspace.Eggs
local PetModels = ReplicatedStorage.Pets
local EggConfig = require(ReplicatedStorage.Config.Eggs)
local template= script.Parent.Template
local function GetRarityColor(rarity: string)
print(rarity)
local color
if rarity == "Common" then
color= Color3.fromRGB(136, 136, 136)
elseif rarity == "Uncommon" then
color= Color3.fromRGB(83, 255, 97)
elseif rarity == "Rare" then
color= Color3.fromRGB(55, 98, 199)
elseif rarity == "Legendary" then
color= Color3.fromRGB(225, 244, 50)
end
return color
end
local function GetChanceColor(chance: number)
print(chance)
if chance <101 then
chance = Color3.fromRGB(255,255,255)
end
return chance
end
local function GenerateViewportFrame(viewportFrame:ViewportFrame, petModel:Model)
petModel:PivotTo(CFrame.new()*CFrame.Angles(0,math.rad(90),0))
petModel.Parent=viewportFrame
local camera = Instance.new("Camera",viewportFrame)
viewportFrame.CurrentCamera= camera
camera.CFrame = CFrame.new(Vector3.new(0,0,3),petModel.PrimaryPart.Position)
end
local function GeneratePet(container: Frame, petConfig: table)
print(petConfig)
local clone = container.template:Clone()
clone.Parent = container
clone.Name = petConfig.Name
clone.Visible = true
clone.ViewportFrame.PetName.Text =petConfig.Chance.."%"
clone.ViewportFrame.PetName.TextColor3 = GetChanceColor(petConfig.Chance)
clone.ViewportFrame.Rarity.Text = petConfig.Rarity
clone.ViewportFrame.Rarity.TextColor3 = GetRarityColor(petConfig.Rarity)
local petClone = PetModels[petConfig.Name]:Clone()
GenerateViewportFrame(clone.ViewportFrame,petClone)
end
local function GenerateBillBoardGui(eggModel:Instance,eggConfig: table)
print(eggConfig)
local Attachment = eggModel.Egg.Attachment
local Clone = template:Clone()
Clone.Parent = script.Parent
Clone.Adornee = Attachment
Clone.Name= eggModel.Name
for _,pet in ipairs(eggConfig.Pets) do
GeneratePet(Clone.Frame.Container, pet)
end
Clone.Frame.Buttons.Auto.MouseButton1Click:Connect(function()
--if not Players.gamepass.AutoHatch.Value then
-- Prompt them to the Purchase the Gamepass
--else
BuyEgg:FireServer(eggModel.Name,"Auto")
-- end
end)
Clone.Frame.Buttons.X1.MouseButton1Click:Connect(function()
BuyEgg:FireServer(eggModel.Name)
end)
Clone.Frame.Buttons.X3.MouseButton1Click:Connect(function()
-- if not Players.gamepass.X3GamePass.Value then
-- Prompt them to the Purchase the Gamepass
-- else
BuyEgg:FireServer(eggModel.Name,"X3")
-- end
end)
end
GenerateBillBoardGui(EggsFolder.Basic_Egg, EggConfig.Basic_Egg)
PetHatched.OnClientEvent:Connect(function(pet: table)
print("We received a"..pet.Name)
local egg = workspace.Egg
local eggClone = workspace.Egg:Clone()
local TweenService = game:GetService("TweenService")
local TweenInfos =TweenInfo.new(2,Enum.EasingStyle.Sine,Enum.EasingDirection.In,0,false,0.4)
local goals = {Size = Vector3.new(5,5,5);}
local HatchEggThingAnimation = TweenService:Create(egg,TweenInfos,goals)
HatchEggThingAnimation:Play()
end)
like I have said. I just need a guide to how to make the egg in workspace appear as a frame/ViewportFrame? with my current values
I don’t know if it helps but here is a photo of module