Hello my code gives this error: ‘‘attempt to index nil with ‘FindFirstChild’ error’’, i looked up some solutions but it didn’t work can somebody help me the script gives me the error on second line of code:
check if the player is nil before running the code, and if it isn’t stop the function.
.Event:Connect(function(player)
if (not player) then
warn("No player argument passed in event RebirthTycoon")
return -- this will stop the function
end
-- rest of the code
No, what I meant is where is the script where you are firing the bindable event using :Fire(), because you arent correctly giving it the player parameter
elseif v:FindFirstChild('Rebirth') and v:FindFirstChild('Rebirth').Value then
if player:FindFirstChild('leaderstats').Cash.Value >= v.Price.Value then
playSound(v, audio.Rebirth.SoundId)
player.leaderstats.Cash.Value -= v.Price.Value
objects[v.Object.Value].Parent = tycoon.Purchases
tycoon.Parent:FindFirstChild('RebirthTycoon'):Fire()
v:Destroy()