AlvinBlox video script not working

Hello!

So I watched a AlvinBlox video to try to learn some basics of scripting but my code doesn’t seem to work?

I haven’t gotten any errors within the output.

Link to video: https://www.youtube.com/watch?v=DhS5oexaE3w&

StarterGui script:


local frame = GUI:WaitForChild("Frame")

local OK = frame:WaitForChild("OK")

local VPF = frame:WaitForChild("ViewportFrame")

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

game.ReplicatedStorage.FoundEgg.OnClientEvent:Connect(function(eggName)
	if game.ReplicatedStorage.Eggs:FindFirstChild(eggName) then
		
		frame.Visible = true
		VPF:ClearAllChildren()
		
		local eggClone = game.ReplicatedStorage.Eggs[eggName]:Clone()
		eggClone.Parent = VPF
		
		frame.YouFound.Text= "Your Found "..eggName.."!"
		
		local camera = Instance.new("Camera")
		camera.Parent = VPF
		VPF.CurrentCamera = camera
		camera.CFrame = eggClone.CFrame * CFrame.new(0,0,eggClone.Size.z * 1.5)
		
	end
end)```

ServerScriptService script: 

```local eggs = game.ReplicatedStorage.Eggs

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```
1 Like

Check your wait. wait (2) is not wait(2). A lot of your code has unnecessary spaces.

2 Likes

Okay, Thank you, I’ll look into that

2 Likes

Can you explain what you’re trying to do?

1 Like

Watch the video I linked and you’ll understand.

1 Like

Do you receive any errors in your console?

1 Like

No, I do not.

(30 chaaaaaaaaaaar)

1 Like

What part of your script isn’t working?

1 Like

Nothing happens when I touch the eggs.

1 Like

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```

**The scripting inside of ServerScriptService ^**
1 Like

That’s the script within ServerScriptService

1 Like

Put this under your variable called plr in your .Touched event:

print(plr.Name)

Tell me if anything shows up in your output now.

1 Like

Where exactly in the code?

(30 chaaaaar)

Put it underneath that variable.

1 Like

Then I get this apparently:

image

1 Like

Everything works completely fine except for when I touch the eggs, nothing happens.

1 Like

Does the remote event actually fire?

1 Like

Check if this works?

if plr then
    game.ReplicatedStorage.FoundEgg:FireClient(plr,eggClone.Name)
    eggClone:Destroy()
end
3 Likes

That works! Thank you so much!!

1 Like