You are also applying changes to the StarterGui instead of the PlayerGui, any changes would not be shown since everything from StarterGui is cloned to the PlayerGui.
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui") or Player.PlayerGui
local EggHatchFrame = PlayerGui.ScreenGui.EggHatchFrame
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 TweenInfos = TweenInfo.new(2,Enum.EasingStyle.Bounce,Enum.EasingDirection.Out,0,false,0)
local TweenService = game:GetService("TweenService")
local EggHatchFrame = game.StarterGui.ScreenGui.EggHatchFrame
local EggsFolder = Workspace.Eggs
local PetModels = ReplicatedStorage.Pets
local part = Workspace.Part
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 megistus = TweenService:Create(EggHatchFrame,TweenInfos,{Position = UDim2.new(0.391, 0,0.5, 0);}):Play()
print("Welp")
end)
This is the script that i mention. If you still haven’t completed the hatching script, do the GUI later. When the player clicks on the proximity prompt or whatever, call this remote event with serversidescript(with the script I linked). Also you dont need to use remote event, If you made the player clicked script in local script. Put the tween in the player clicked script.