#opening egg animation
1 messages · Page 1 of 1 (latest)
this is my script for opening the egg:
`local replicatedStorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local remotes = replicatedStorage.Remotes
local eggs = workspace.MainFodler_Workspace.Eggs
local playerHatchDebounce = {}
local function chooseRandomPet(petTable)
local chosenPet = nil
local randomNumber = math.random(1, 100)
local weight = 0
for i, v in pairs(petTable) do
weight += v.chance
if weight >= randomNumber then
chosenPet = v
break
end
end
return chosenPet
end
for _, egg in pairs(eggs:GetChildren()) do
egg.ProximityPrompt.Triggered:Connect(function(player)
local eggData = require(egg.Data)
local price = eggData.eggPrice
local currency = eggData.eggCurrency
if player.leaderstats.Coins.Value >= price then
if not playerHatchDebounce[player] then
playerHatchDebounce[player] = true
local chosenPet = chooseRandomPet(eggData.eggPets)
player.leaderstats[currency].Value -= price
remotes.HatchEgg:FireClient(player, egg.Name, chosenPet)
local val = Instance.new("StringValue")
val.Name = tostring(chosenPet.petName)
val.Parent = player.Pets
task.wait(6)
playerHatchDebounce[player] = false
end
end
end)
end
players.PlayerRemoving:Connect(function(player)
if playerHatchDebounce[player] then
playerHatchDebounce[player] = nil
end
end)`
Add prints and pcalls
whats a pcall?
im very new to this stuff
everything works besides the actual opening animation, it takes my money but just doesnt play the animation
i need both scripts that fire the eggs functionality and animation
i think its this
this is the animation script