You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I am trying to make a pet hatch animation with a viewport frame (so egg model and pet model) and this animation happens after a remote event from the server is fired. The parameters are 6 (because of another script that uses the same remote event) -
What is the issue? Include screenshots / videos if possible!
The issues is that whenever the pet is suppose to show up, an error is caused, which basically im indexing a nil value. I tried debugging and figured out that whenever the client receives the pet model, it receives a nil value, tho i dont understand how as i have an eggmodel passed from the server which works fine (maybe because i sent the eggmodel to the server then have it back to the client). -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried to look issues like this and there are, but the issues i find have always the same answer: “The client cannot acces the server storage”, though the pet models are in replicated storage.
This is the server side code:
local function Hatch(player, eggId, amount, eggModel)
if HatchCooldown[player.UserId] then return end
local eggConfig = EggConfig[eggId]
local playerBalance = player.leaderstats.Money.Value
if playerBalance < eggConfig.Price then return end
HatchCooldown[player.UserId] = true
player.leaderstats.Money.Value -= eggConfig.Price
local chosenPet = ChoosePet(eggConfig.Pets)
local petModel = petModels[chosenPet.ID]:Clone()
local petInstance = Rewards.Pet(player, chosenPet.ID, chosenPet.Rarity, amount)
print(petModel)
PetHatched:FireClient(player, chosenPet, petInstance, eggId, eggModel, petModel)
task.delay(HATCH_COOLDOWN, function()
HatchCooldown[player.UserId] = nil
end)
end
the client side:
PetHatched.OnClientEvent:Connect(function(pet, amount, petInstance, eggId, eggModel, petModel)
print(petModel)
viewportHatch.Size = UDim2.fromScale(0, 0)
local eggModel = eggModel:Clone()
eggModel.Parent = viewportHatch
eggModel.CFrame = CFrame.new(0, 0, 0)
print(petModel) --receives nil
petModel:PivotTo(CFrame.new(0, 0, 0))--the error
petModel.Parent = viewportHatch
--this isnt the full code, i just made it shorter
end)