Unable to assign property Text. string expected, got Instance

  1. What do I want to achieve? To have my system work

  2. What is the issue? Even though it is a string value, my game says it is an instance

  3. What solutions have you tried so far? Tried to say [Instance].Name still doesn’t work

So basically im making an egg system but the thing is it doesn’t work because of this error.

local rep = game:GetService("ReplicatedStorage")
local runs = game:GetService("RunService")
local model3D = require(rep:WaitForChild("Module3D"))
local tweeny = game:GetService("TweenService")
local uis = game:GetService("UserInputService")

local plr = game.Players.LocalPlayer
local cam = workspace.Camera
local pets = rep:WaitForChild("Pets")
local eggs = workspace:WaitForChild("Nidus")
local distance  = 40

local canhatch = nil
local ishatch = false
local hatch1connect = nil
local cooldown = false
wait(3)

local function animatebilly(billboard , openorclose)
	if openorclose == true then
		tweeny:Create(billboard, TweenInfo.new(0.1),{Size = UDim2.new(15, 0,20, 0)}):Play()
	else
		tweeny:Create(billboard, TweenInfo.new(0.2),{Size = UDim2.new(0,0,0, 0)}):Play()
		wait(.3)
		billboard.Enabled = false
	end
	wait(1)
end

local function togglegui(bool)
	for i,v in pairs(script.Parent.Parent.Parent:GetChildren()) do
		if v.Name ~= "EggSystem" then
			v.Enabled = bool
		end
	end
end



for i,v in pairs(eggs:GetChildren()) do
	local eggpets = pets:FindFirstChild(v.Name)
	
	if eggpets ~= nil then
		
		
		local billboardtemp = script.Template:Clone()
		local container = billboardtemp:WaitForChild("Cointainer")
		local frame = container:WaitForChild("Main_Frame")
		local template = frame:WaitForChild("Template")
		local billboardegg = script.Parent.Parent.Eggboards
		local port = template:WaitForChild("Port")
		
		billboardtemp.Adornee = v.EggMesh
		billboardtemp.Name = v.Name
		billboardtemp.Enabled = true
		billboardtemp.Parent = billboardegg
		
		local petz = {}

		for x, pet in pairs(eggpets:GetChildren()) do
			table.insert(petz, pet.Rarity.Value)

		end
		table.sort(petz)
		
		for i = 1, math.floor(#petz/2) do
			local j = #petz - i + 1
			petz[i], petz[j] = petz[j], petz[i]
		end
		
		for _,rarity in pairs(petz) do
			for _, pet in pairs(eggpets:GetChildren()) do
				if pet.Rarity.Value == rarity then
					local rarity = pet.Rarity.Value



					local clonedtemp = template:Clone()
					clonedtemp.Name = pet.Name

					clonedtemp.Rarity.Text = tostring(pet.Rarity.Value).."%"
					clonedtemp.Visible = true
					clonedtemp.Parent = frame

					local petmodel = model3D:Attach3D(clonedtemp.Port,pet:Clone())
					petmodel:SetDepthMultiplier(1.2)
					petmodel.Camera.FieldOfView = 5
					petmodel.Visible = true

					runs.RenderStepped:Connect(function()
						petmodel:SetCFrame(CFrame.Angles(0,tick() % (math.pi * 2),0) * CFrame.Angles(math.rad(-10),0,0))
					end)
					break
				else
					continue
				end
			end
		end
		
	
			
		 runs.RenderStepped:Connect(function()
			if plr:DistanceFromCharacter(v.EggMesh.PrimaryPart.Position) < distance then
					if billboardtemp.Name ~= v.Name then
					canhatch = true
					
					animatebilly(billboardtemp, true)
					billboardtemp.Enabled = true
					else
						canhatch = true
					
					animatebilly(billboardtemp, true)
					billboardtemp.Enabled = true
						
					end
			else
				animatebilly(billboardtemp, false)
				
				canhatch = false
			end
			
		end)
	end
end

local function hatch1(petName,egg)
	print(petName)
	togglegui(false)
	
	local pet = pets[egg.Name]:FindFirstChild(petName):Clone()
	
	ishatch = true
	local eggmesh = egg:FindFirstChild("EggMesh"):Clone()
	script.Parent.Parent.PetDusp.petnaem.Text = pet.Name
	print(egg.Name)
	for i,v in pairs(eggmesh:GetChildren()) do
		if v:isA("BasePart") then
			v.Anchored = true
			v.CanCollide = false
		end
	end
	hatch1connect = runs.RenderStepped:Connect(function()
		local cf = CFrame.new(0, 0,-eggmesh.PrimaryPart.Size.Z * 2) * CFrame.Angles(math.sin(time() *4)*2,math.sin(time() *4) *2,math.sin(time() *4) * 2)
		eggmesh:SetPrimaryPartCFrame(cam.CFrame * cf)
	end)
	eggmesh.Parent = cam
	wait(3)
	for i,v in pairs(eggmesh:GetChildren()) do
		if v:isA("BasePart") then
			tweeny:Create(v, TweenInfo.new(0.3),{Transparency = 1}):Play()
		end
	end
	wait(0.3)
	hatch1connect:Disconnect()
	eggmesh:Destroy()
	script.Parent.Parent.PetDusp.Visible = true
	
	local petmodel = model3D:Attach3D(script.Parent.Parent.PetDusp,pet)
	petmodel:SetDepthMultiplier(1.2)
	petmodel.Camera.FieldOfView = 5
	petmodel.Visible = true

	runs.RenderStepped:Connect(function()
		petmodel:SetCFrame(CFrame.Angles(0,tick() % (math.pi * 2),0) * CFrame.Angles(math.rad(-10),0,0))
	end)
	wait(3)
	tweeny:Create(script.Parent.Parent.PetDusp:FindFirstChildOfClass("ViewportFrame"), TweenInfo.new(0.5), {ImageTransparency = 1}):Play()
	wait(0.5)
	for i, v in pairs(script.Parent.Parent.PetDusp:GetDescendants()) do
		if v:IsA("ViewportFrame") then
			v:Destroy()
			script.Parent.Parent.PetDusp.Visible = true
		end
	end
	script.Parent.Parent.PetDusp.Visible = false
	
	togglegui(true)
	_G.newTemp(petName)
end

local function triplehatch(petName,petName2,petName3,egg)
	togglegui(false)
	
	local pet = pets[egg.Name]:FindFirstChild(petName):Clone()
	local pet2 = pets[egg.Name]:FindFirstChild(petName2):Clone()
	local pet3 = pets[egg.Name]:FindFirstChild(petName3):Clone()
	
	--where the error comes
	script.Parent.Parent.PetDusp.petnaem.Text = petName
	script.Parent.Parent.PetDusp2.petnaem.Text = petName2
	script.Parent.Parent.PetDusp3.petnaem.Text = petName3
	ishatch = true
	local eggmesh = egg:FindFirstChild("EggMesh"):Clone()
	local eggmesh2 = egg:FindFirstChild("EggMesh"):Clone()
	local eggmesh3 = egg:FindFirstChild("EggMesh"):Clone()
	for i,v in pairs(eggmesh:GetChildren()) do
		if v:isA("BasePart") then
			v.Anchored = true
			v.CanCollide = false
		end
	end
	
	for i,v in pairs(eggmesh2:GetChildren()) do
		if v:isA("BasePart") then
			v.Anchored = true
			v.CanCollide = false
		end
	end
	
	for i,v in pairs(eggmesh3:GetChildren()) do
		if v:isA("BasePart") then
			v.Anchored = true
			v.CanCollide = false
		end
	end
	
	
	hatch1connect = runs.RenderStepped:Connect(function()
		local cf = CFrame.new(0, 0,-eggmesh.PrimaryPart.Size.Z * 2) * CFrame.Angles(math.sin(time() *4)*2,math.sin(time() *4) *2,math.sin(time() *4) * 2)
		eggmesh:SetPrimaryPartCFrame(cam.CFrame * cf)
		
		local cf2 = CFrame.new(6, 0,-eggmesh.PrimaryPart.Size.Z * 2) * CFrame.Angles(math.sin(time() *4)*2,math.sin(time() *4) *2,math.sin(time() *4) * 2)
		eggmesh2:SetPrimaryPartCFrame(cam.CFrame * cf2)
		
		local cf3 = CFrame.new(-6, 0,-eggmesh.PrimaryPart.Size.Z * 2) * CFrame.Angles(math.sin(time() *4)*2,math.sin(time() *4) *2,math.sin(time() *4) * 2)
		eggmesh3:SetPrimaryPartCFrame(cam.CFrame * cf3)
	end)
	eggmesh.Parent = cam
	eggmesh2.Parent = cam
	eggmesh3.Parent = cam
	wait(3)
	ishatch = false
	for i,v in pairs(eggmesh:GetChildren()) do
		if v:isA("BasePart") then
			tweeny:Create(v, TweenInfo.new(0.3),{Transparency = 1}):Play()
		end
	end
	
	for i,v in pairs(eggmesh2:GetChildren()) do
		if v:isA("BasePart") then
			tweeny:Create(v, TweenInfo.new(0.3),{Transparency = 1}):Play()
		end
	end
	
	for i,v in pairs(eggmesh3:GetChildren()) do
		if v:isA("BasePart") then
			tweeny:Create(v, TweenInfo.new(0.3),{Transparency = 1}):Play()
		end
	end
	wait(0.3)
	hatch1connect:Disconnect()
	eggmesh:Destroy()
	eggmesh2:Destroy()
	eggmesh3:Destroy()
	script.Parent.Parent.PetDusp.Visible = true
	script.Parent.Parent.PetDusp2.Visible = true
	script.Parent.Parent.PetDusp3.Visible = true

	local petmodel = model3D:Attach3D(script.Parent.Parent.PetDusp,pet)
	petmodel:SetDepthMultiplier(1.2)
	petmodel.Camera.FieldOfView = 5
	petmodel.Visible = true
	
	local petmodel2 = model3D:Attach3D(script.Parent.Parent.PetDusp2,pet2)
	petmodel2:SetDepthMultiplier(1.2)
	petmodel2.Camera.FieldOfView = 5
	petmodel2.Visible = true
	
	local petmodel3 = model3D:Attach3D(script.Parent.Parent.PetDusp3,pet3)
	petmodel3:SetDepthMultiplier(1.2)
	petmodel3.Camera.FieldOfView = 5
	petmodel3.Visible = true
	

	runs.RenderStepped:Connect(function()
		petmodel:SetCFrame(CFrame.Angles(0,tick() % (math.pi * 2),0) * CFrame.Angles(math.rad(-10),0,0))
		petmodel2:SetCFrame(CFrame.Angles(0,tick() % (math.pi * 2),0) * CFrame.Angles(math.rad(-10),0,0))
		petmodel3:SetCFrame(CFrame.Angles(0,tick() % (math.pi * 2),0) * CFrame.Angles(math.rad(-10),0,0))
	end)
	
	
	wait(3)
	tweeny:Create(script.Parent.Parent.PetDusp:FindFirstChildOfClass("ViewportFrame"), TweenInfo.new(0.5), {ImageTransparency = 1}):Play()
	tweeny:Create(script.Parent.Parent.PetDusp2:FindFirstChildOfClass("ViewportFrame"), TweenInfo.new(0.5), {ImageTransparency = 1}):Play()
	tweeny:Create(script.Parent.Parent.PetDusp3:FindFirstChildOfClass("ViewportFrame"), TweenInfo.new(0.5), {ImageTransparency = 1}):Play()

	wait(0.5)
	for i, v in pairs(script.Parent.Parent.PetDusp:GetDescendants()) do
		if v:IsA("ViewportFrame") then
			v:Destroy()
			script.Parent.Parent.PetDusp.Visible = true
		end
	end
	
	for i, v in pairs(script.Parent.Parent.PetDusp2:GetDescendants()) do
		if v:IsA("ViewportFrame") then
			v:Destroy()
			script.Parent.Parent.PetDusp2.Visible = true
		end
	end
	
	for i, v in pairs(script.Parent.Parent.PetDusp3:GetDescendants()) do
		if v:IsA("ViewportFrame") then
			v:Destroy()
			script.Parent.Parent.PetDusp3.Visible = true
		end
	end
	script.Parent.Parent.PetDusp.Visible = false
	script.Parent.Parent.PetDusp2.Visible = false
	script.Parent.Parent.PetDusp3.Visible = false
	ishatch = false
	togglegui(true)
	_G.newTemp(petName)
	_G.newTemp(petName2)
	_G.newTemp(petName3)
end


uis.InputBegan:Connect(function(input)
	local billboardtemp = script.Template
	local clonedtemp = billboardtemp.Cointainer.button
	if input.KeyCode == Enum.KeyCode.E then
		if plr.Character ~= nil and ishatch == false then
			local plrps = plr.Character.HumanoidRootPart.Position
			local nearsetg
			for i,v in pairs(eggs:GetChildren()) do
				for i,v in pairs(eggs:GetChildren()) do
					if nearsetg == nil then
						nearsetg = v
					else
						if (plrps - v.EggMesh.PrimaryPart.Position).Magnitude < (nearsetg.EggMesh.PrimaryPart.Position).Magnitude then
							nearsetg = v
						end
					end
				end
			end
			if plr:DistanceFromCharacter(nearsetg.EggMesh.PrimaryPart.Position) < distance then
				canhatch = true

			else
				canhatch = false
			end
			if canhatch == true then
				if canhatch == true then
					local result = rep: WaitForChild("EggHatchingRemotes"):WaitForChild("hatchserver"):InvokeServer(nearsetg)
					if result ~= nil then
						if not cooldown then
							cooldown = true
							hatch1(result,nearsetg)
							wait(0.1)
							cooldown = false
						end
					end
					
			end
		end
	end
		
	end
	
	if input.KeyCode == Enum.KeyCode.R  then
		if plr.Character ~= nil and ishatch == false then
			local plrps = plr.Character.HumanoidRootPart.Position
			local nearsetg
			for i,v in pairs(eggs:GetChildren()) do
				for i,v in pairs(eggs:GetChildren()) do
					if nearsetg == nil then
						nearsetg = v
					else
						if (plrps - v.EggMesh.PrimaryPart.Position).Magnitude < (nearsetg.EggMesh.PrimaryPart.Position).Magnitude then
							nearsetg = v
						end
					end
				end
			end
			if plr:DistanceFromCharacter(nearsetg.EggMesh.PrimaryPart.Position) < distance then
				canhatch = true

			else
				canhatch = false
			end
			if canhatch == true then
				if canhatch == true then
					local result1 , result2, result3 = rep.EggHatchingRemotes.hatch3pets:InvokeServer(nearsetg)
					if result1 ~= nil and result2 ~= nil and result3 ~= nil then
						if not cooldown then
							cooldown = true
							triplehatch(result1, result2, result3, nearsetg)
							wait(0.1)
							cooldown = false
						end
						
					
					end

				end
			end
		end

	end
end)

for i,v in pairs(script.Parent.Parent.Eggboards:GetChildren()) do
	
	local ebtn = v.Cointainer.button.Open_one
	local rbtn = v.Cointainer.button.Open_three
	
	ebtn.MouseButton1Click:Connect(function()
		if plr.Character ~= nil and ishatch == false then
		
			local nearsetg
			local plrps = plr.Character.HumanoidRootPart.Position
			
			for i,v in pairs(eggs:GetChildren()) do
				for i,v in pairs(eggs:GetChildren()) do
					if nearsetg == nil then
						nearsetg = v
					else
						if (plrps - v.EggMesh.PrimaryPart.Position).Magnitude < (nearsetg.EggMesh.PrimaryPart.Position).Magnitude then
							nearsetg = v
						end
					end
				end
				if plr:DistanceFromCharacter(nearsetg.EggMesh.PrimaryPart.Position) < distance then
					canhatch = true

				else
					canhatch = false
				end
				if canhatch == true then
					
						local result = rep:WaitForChild("EggHatchingRemotes"):WaitForChild("hatchserver"):InvokeServer(nearsetg)
						if result ~= "Cannot hatch" then
							if not cooldown then
								cooldown = true
								triplehatch(result,nearsetg)
								wait(0.1)
								cooldown = false
							end


						end

					end
				end
			end
		
	end)
	
	rbtn.MouseButton1Click:Connect(function()
		if plr.Character ~= nil and ishatch == false then
			local plrps = plr.Character.HumanoidRootPart.Position
			local nearsetg
			for i,v in pairs(eggs:GetChildren()) do
				for i,v in pairs(eggs:GetChildren()) do
					if nearsetg == nil then
						nearsetg = v
					else
						if (plrps - v.EggMesh.PrimaryPart.Position).Magnitude < (nearsetg.EggMesh.PrimaryPart.Position).Magnitude then
							nearsetg = v
						end
					end
				end
			end
			if plr:DistanceFromCharacter(nearsetg.EggMesh.PrimaryPart.Position) < distance then
				canhatch = true

			else
				canhatch = false
			end
			if canhatch == true then
				if canhatch == true then
					local result1 , result2, result3 = rep.EggHatchingRemotes.hatch3pets:InvokeServer(nearsetg)
					if result1 ~= nil and result2 ~= nil and result3 ~= nil then
						if not cooldown then
							cooldown = true
							triplehatch(result1, result2, result3, nearsetg)
							wait(0.1)
							cooldown = false
						end


					end

				end
			end
		end 
	end)
	
end 

Please help me ASAP. Thanks in advance!

This should be Rarity.Value, StringValues don’t have a Text property

Hello, it is actually a textlabel. That part works fine. Only at line 189 it erros.

  1. It would help if you could separately reply with the line(s) that aren’t working because it’s really hard to find the line that is erroring in all of your code.

  2. You can try wrapping the text inside a tostring() function.

Hello!

I used tostring function it does one part of the code correctly but an error pops up:

Players.itzmerose_12.PlayerGui.EggSystem.Clientscripts.Hatch_Client:184: attempt to index nil with 'Name'

where it occurs:

local function triplehatch(petName,petName2,petName3,egg)
	togglegui(false)
	
	local pet = pets[egg.Name]:FindFirstChild(petName):Clone()
	local pet2 = pets[egg.Name]:FindFirstChild(petName2):Clone()
	local pet3 = pets[egg.Name]:FindFirstChild(petName3):Clone()
	
	--where error occurs
	script.Parent.Parent.PetDusp.petnaem.Text = tostring(petName)
	script.Parent.Parent.PetDusp2.petnaem.Text = tostring(petName2)
	script.Parent.Parent.PetDusp3.petnaem.Text = tostring(petName3)

It might be referring to egg.Name, and saying that egg does not exist. Make sure whatever “egg” is supposed to be exists, and has a Name property.

it is parameter in the function. So how can i assure it has a name?

And also it works when i open only i egg, but when i open three eggs, this error doesn’t appear.

I seem to be having the same issue, but when I try to assign the text button’s text to another text label’s text it seems to put the text’s text as “Instance” when I wrap it in tostring()

try using .Name when u’re using tostring

I think I’ve fixed it. Thank you though!