Egg Hunt Script Not working

Since Roblox cancelled their egg hunt, I wanted to make another one for the 2 people who play my game, so I looked up an Alvinblox tutorial from last year and tried it. I have no idea what I did wrong but it wont work? Here is the game:
image
image
(Egg Spawns Script)


(Client Script)

I am not a good developer so I have no idea what is going on, can someone help me?

image

LUA is case-sensitive when using your variables, replace it with:

OK.MouseButton1Click:Connect(function()
    frame.Visible = false
end)
1 Like

I’ve tried and it still wont work?

I’ve opened the output and this is what I’m getting:

Ah

Eggs can’t be models, as they don’t have a Position property

You could implement another check as well if the Egg selected is a Model, then use the MoveTo() or SetPrimaryCFrame() function to move it

(Or you could simply make the egg a regular BasePart)

I tried removing the modeled eggs but the other eggs wont work either, I am so confused?
I keep getting these errors:
MouseButton1Down is not a valid member of Plugin “cloud_6510033363”

That’s a Plugin I’m assuming, so it’s not related to the actual script

Do you know how to format code?

```Like this```

Could you format both the Server & Local script? Maybe 1 of your Spawns/Eggs are positioned somewhere else?

(egg spawner)


local spawns = game.Workspace.EggSpawns

while wait(2) do

local eggsTable = eggs:GetChildren()

local randomEgg = eggsTable[math.random(1,#eggsTable)]

local spawnsTable = spawns:GetChildren()

local randomSpawn = spawnsTable[math.random(1,#spawnsTable)]


local eggClone = randomEgg:Clone()
eggClone.Parent = game.Workspace.SpawnedEggs

eggClone.Position = randomSpawn.Position + Vector3.new(0,20,0)
eggClone.Anchored = false

eggClone.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	
	if plr == true then	
		game.ReplicatedStorage.FoundEgg:FireClient(plr,eggClone.Name)
		eggClone:Destroy()
	end
	
end)

end

i tried :confused:

local spawns = game.Workspace.EggSpawns
local eggs = game.ReplicatedStorage.Eggs

while wait(2) do
    local eggsTable = eggs:GetChildren()
    print(eggsTable)
    local randomEgg = eggsTable[math.random(1,#eggsTable)]
    print(randomEgg)
    local spawnsTable = spawns:GetChildren()
    local randomSpawn = spawnsTable[math.random(1,#spawnsTable)]
    
    local eggClone = randomEgg:Clone()
    eggClone.Parent = game.Workspace.SpawnedEggs
    eggClone.Position = randomSpawn.Position + Vector3.new(0,20,0)
    eggClone.Anchored = false
    print(eggClone.Position)
    print(eggClone)

    eggClone.Touched:Connect(function(hit)
	    local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	
	    if plr == true then	
            print("Hit!")
		    game.ReplicatedStorage.FoundEgg:FireClient(plr,eggClone.Name)
		    eggClone:Destroy()
	    end
    end)
end

Can you try this and see what Outputs?

it works but the eggs keep spawning in and the gui wont pop up it wont let me collect them

Hm

local GUI = script.Parent
local Frame = GUI:WaitForChild("Frame")
local OK = Frame:WaitForchild("OK")
local VPF = Frame:WaitForChild("ViewportFrame")

print("Script running")

OK.MouseButton1Click:Connect(function()
    Frame.Visible = false
    print("Hiding frame")
end)

game.ReplicatedStorage.FoundEgg.OnClientEvent:Connect(function(EggName)
    if game.ReplicatedStorage.Eggs:FindFirstChild(EggName) then
        print("Found an egg!")
        Frame.Visible = true
        VPF:ClearAllChildren()

        local Clone = game.ReplicatedStorage.Eggs[EggName]:Clone()
        Clone.Parent = VPF

        Frame.YouFound.Text = "You Found "..EggName.."!"

        print("Changing camera")
        local Cam = Instance.new("Camera")
        Cam.Parent = VPF
        VPF.CurrentCamera = Cam
        Cam.CFrame = Clone.CFrame * CFrame.new(0, 0, EggClone.Size.Z * 1.5)
    else
        print("Didn't find a valid egg!")
    end
end)

Try this LocalScript?

same output :confused: the gui still wont spawn and the eggs dont despawn

Well, the eggs won’t despawn because you’ve encased it in a loop

Unless if you don’t wanna break it, you could just do for Loop = 1, 10 do loop instead

For the Client script, is there anything printing at all?

2 Likes