Hello, so i just finished making my egg hatching system but there was 1 thing left to do it was the datastore but the thing is the pets gets added on the player’s inventory folder from a local script so they are not visible on the server so they cant get saved here is my script:
local Folder = game.ReplicatedStorage.Folder
local rfolder = Folder:GetChildren()
local player = game.Players.LocalPlayer
local viewportframe = script.Parent.Frame.ViewportFrame
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
local chosenPet = rfolder[math.random(1, #rfolder)]
script.Parent.Frame:TweenPosition(UDim2.new(0.344, 0,0.205, 0),Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 0.5, true)
chosenPet:Clone().Parent = player.Inventory
local clonedpet = chosenPet:Clone()
clonedpet.Parent = viewportframe
script.Parent.Frame.TextLabel.Text = "You got "..chosenPet.Name.."!"
local cam = Instance.new("Camera")
cam.CFrame = CFrame.new(clonedpet.PrimaryPart.Position + (chosenPet.PrimaryPart.CFrame.lookVector * 4) + Vector3.new(1,1.5,1) ,clonedpet.PrimaryPart.Position)
cam.Parent = viewportframe
viewportframe.CurrentCamera = cam
wait(1)
script.Parent.Frame:TweenPosition(UDim2.new(0.344, 0,1, 0),Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 0.5, true)
viewportframe:ClearAllChildren()
end)
Thank you!