Problem with receiving parameters

so basically i wanted to make a pet system i tried myself i couldn’t figure out how to make the pet models follow you so i scrapped my entire scripts and i saw alvinblox posted a vid on pet system so i copied that and when i send the pet param it just says nil value so for example if i want the name of the pet so pet.Name it will say ‘attempt to index nil with Name’

the script

local PetModule = require(game.ServerScriptService:WaitForChild("PetModule"))

script.Parent.ClickDetector.MouseClick:Connect(function(plr)

	if plr.Stats.Coins.Value >= 100 then

		plr.Stats.Coins.Value = plr.Stats.Coins.Value - 100

		local pet = PetModule.ChoosePet()

		print(pet.Name.." selected")

		game.ReplicatedStorage.HatchEgg:FireClient(plr)

	end

end)

local script

game.ReplicatedStorage.HatchEgg.OnClientEvent:Connect(function(pet)

so for example if i say print(pet.Name) after the function it will say attempt to index nil with Name

2 Likes

When you’re firing the client event, you aren’t sending the pet as an argument. game.ReplicatedStorage.HatchEgg:FireClient(plr, pet) should work.

1 Like

thx alot
i did try this before with ‘plr, pet’ but in the top function anyways thx alot been stuck on it for a bit now

1 Like