So I'm trying to make, what I would call, a mini Egg Hunt where there's only like 5-6 Eggs to collect. I have the models for the Eggs, but I have no idea how I'd go about scripting the Eggs to recognize when you pick them up and add them to a value. I want to make it so when you get the Eggs it plays an animation, adds the egg value to some kind of thing that records how many you've collected, then boots you back to spawn. Any help? not really looking for someone to write a script, more looking for someone to point me in the right directions
I'm not sure how I would go about scripting Eggs, any help?
1 answer
Ok, so since you are only asking for pointers, and not requesting, I will gladly help.
Sorry about indentation, I'm on an iPad that won't work with me
You will have to work out the saving on your own, as I can only point you in the right direction, not give you full scripts. I'm already pushing it by showing you this much, so bare with me.
So here, we are creating two tables.
Datalist holds all of the players data. The second table is the unique data of the single player
local datalist = {}
game:GetService("Players").PlayerAdded:Connect(function(plr)
datalist[plr.UserId] = {} --A Table that will hold the names of the eggs Collected
end)
--have a bindable or remote event that listens for when the touched event sends through the information
AddEggToInventory.Event:Connect(function(player, egg)
--check if the players data exists
local mydata = datalist[player.UserId]
if not mydata then return end
--check if the player has the egg already, if not, then add it
end)
So what you want is a listener for the touched event, and then fire a bind able function, or a remote function, depending on if you are using a local script, or a global script to listen for the touched event.
BindableEvents for Regular scripts, remotes for local.
local Storage = game:GetService("ReplicatedStorage")
local AddEggToInventory = Storage:WaitForChild("AddEggToInventory")
--use a touched event, and check if the touched parts parent is a character, if so, then get the player from the character, and fire AddEggToInventory.
--pass the player, and the egg type as arguments through the event
AddEggToInventory:Fire() --send the player, and the egg type
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
For more information, discord is Despayr#2834
Thanks, I'll add you on Discord and try this stuff out to see how it works