Need help for my entire pet system

Hey developers!

I’m developing my first game with my friend and we’re absolutly stuck on the entire pet system .
To be honest, we’re lost.
We found a working follow script for the pets but it is not perfect:


local base = script.Parent
local hearth = base.Parent.Parent:WaitForChild(“Head”)
local runservice = game:GetService(“RunService”)

runservice.Stepped:Connect(function()
local cf = hearth.CFrame
local pos = (hearth.CFrame * CFrame.new(-4,1,4)).p

base.BodyGyro.CFrame = cf
base.BodyPosition.Position = pos
end)


What do you think about it? Do you have some ideas to improve this script?

Our biggest problem is for the Egg hatching system, the pet inventory and the pet data storage.

Does anyone of you can help us achieve this part of our game?
I’m near my computer,
Thank you for reading me,
Padrox (Was “Abdelcrepe” before haha)

4 Likes

I’m pretty sure Alvin Blox has a tutorial on the egg hatching system. You could watch that and follow along with it?

AlvinBlox doesn’t have made a video on how to make an egg hatching system.
Maybe, you’re right with all youtube videos i can problably make the egg hatching system but I still have a problem on Pet data saving and Pet inventory :confused:

3 Likes

How are you attempting to store the pet data? Also if you haven’t used DataStore2 by @Kampfkarren you should consider doing that, as it is a reliable DataStore Module.

There is a really good egg hatching video on YouTube. You can check it out here. As for the pets, the best thing to do is look at a free model, study the scripts, then try making your own. Hope this helps!

I already seen this video, it helps me a lot but i was looking for a solution on how to change the click detector to a “E pressed function”.
And how i said before, i’m probably able to make my egg hatching system,
but there is still two problems wich are the pet storage and the pet inventory (Equip/Unequip)
Thank you for your help!

1 Like

It seems to be a great method to save my data pets but how can i save the data of my pets?
Should i use tables + this "DataStore2 by @Kampfkarren?

1 Like

You can check the distance from the player and the part (the magnitude). If it’s your desired distance, then make a billboard gui show up. After that, you can use UserInputService to see if the player has pressed “e”.

1 Like

Can you send me the video links or what you entered in your search bar because i don’t find any video about this on his channel.

Thank you for the method.
I will try doing this :slight_smile:

Does anyone of you have an idea on how can i make a pet inventory like show the pet icon and how to make an equip and unequip. I don’t know how to put the pet after getting it after the egg hatching :confused:

Try setting the pets network owner to the player.

No, but he does have a simulator shop series that could possibly help with pet saving.
Link: https://www.youtube.com/watch?v=7Bn1KfDDQu0
I also found this video that might help with the equip and unequip:
https://www.youtube.com/watch?v=iBdn7-CiNJk

Mhh, intristing but I don’t how can I do that…
Do you have an idea or should i go check on internet?

Thank you,
I will check those videos and make you a feedback if I achieve this part!
Thank you for all your support!

1 Like

Yes, I would save the pet data as a table.

For example:

local petData = {
    n = "petName";
    cn = "petCustomName";
    id = game:GetService("HttpService"):GenerateGUID(false); -- unique id
    e = false; -- equipped
    xp = 0;
};

For setting networkownership when you spawn the pet in the server you would use something like this:

-- Task: Set pet PrimaryPart network owner to player

local pet = petDir[pet]:Clone()
pet.Parent = workspace
pet.PrimaryPart:SetNetworkOwner(player)


-- Next in a LocalScript you would control the physics or whatever you want to do and it will automatically replicate to the server
1 Like

Thank you so much for all your help and support.
I’m not on Roblox Studio right now.
I will try all of this tomorow (Eur. hour)
See ya later,
I’ll give you a feedback :slight_smile:

1 Like

To make the pet follow the player, I need to use the “ToMove” function to make the entire pet model follow the player, (to exploit the PrimaryPart, that’s it?

1 Like

Essentially yes, you would want to manipulate the position of the PrimaryPart while all the other parts of the pet are welded to the PrimaryPart.

I would either use BodyGyro’s & BodyPosition’s, or use TweenService to add a smooth transition to the pet.

1 Like