Script cloning wrong objetc

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want a house clone if the house name is equal to the button after the button clicked and move to a scripted position.

  2. What is the issue? Include screenshots / videos if possible!

when the button clicked, another house that its name is not equal to the button name cloned

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried to look for solutions but I can’t find any of them that related to my problem

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

I use the remote event to clone the house

this is code from the script in serverscriptservice

local frame = game.StarterGui.HouseGui.HouseFrame.ScrollingFrame:GetChildren()
local houses = game.ReplicatedStorage.House:GetChildren()
local pos = game.Workspace.PromptInterract.HouseOwning:GetChildren()
local event = game.ReplicatedStorage.Remotes.CloneHouseOne1

event.OnServerEvent:Connect(function(player)
	print("getting player from frame")
		
	for i , v in pairs(frame)do
		for _ , house in pairs(houses)do
			for k , p in pairs(pos)do
				  if v.Name == house.Name and v:WaitForChild("Name").Value == house.Name then
			        print("getting houses form frame")
				    if p:WaitForChild("PlayerPlcae").Value == player.Name then
				        print("getting position house")
					    local clone = house:Clone()
					    print("cloning house for player")
					    clone.Parent = game.Workspace:WaitForChild(player.Name.."Stuff")
					   	print("set house parent")
					   	clone:SetPrimaryPartCFrame(p:WaitForChild("HouseSpawnPart").CFrame + Vector3.new(0,7,0) , v.CFrame.LookVetcor)
					   	print("set hosue position")
					    p.ProximityPrompt.Enabled = false
						v.Visible = false
					end
				end
			end
		end
	end
end)

this is code from the local script in the button:

script.Parent.Activated:Connect(function()
	game.ReplicatedStorage.Remotes.CloneHouseOne1:FireServer()
	print("fired form server")
end)

I’m sorry if you guys can’t understand what I’m saying

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

Can you show me your hierarchy

Im sorry im still new to this stuff, but what is ** hierarchy** mean

your explorer, where you see all the ui’s, objects, services for like an example: workspace

Why are you getting the StarterGui? That’s only replicated across the server, and will only check for what the server’s GUI sees

If you want to what the Player’s Gui currently has, use the PlayerGui instead:

local houses = game.ReplicatedStorage.House:GetChildren()
local pos = game.Workspace.PromptInterract.HouseOwning:GetChildren()
local event = game.ReplicatedStorage.Remotes.CloneHouseOne1

event.OnServerEvent:Connect(function(player)
	print("getting player from frame")
	local frame = player.PlayerGui:WaitForChild("HouseGui"):WaitForChild("HouseFrame").ScrollingFrame:GetChildren()
	for i , v in pairs(frame)do
		for _ , house in pairs(houses)do
			for k , p in pairs(pos)do
				  if v.Name == house.Name and v:WaitForChild("Name").Value == house.Name then
			        print("getting houses form frame")
				    if p:WaitForChild("PlayerPlcae").Value == player.Name then
				        print("getting position house")
					    local clone = house:Clone()
					    print("cloning house for player")
					    clone.Parent = game.Workspace:WaitForChild(player.Name.."Stuff")
					   	print("set house parent")
					   	clone:SetPrimaryPartCFrame(p:WaitForChild("HouseSpawnPart").CFrame + Vector3.new(0,7,0) , v.CFrame.LookVetcor)
					   	print("set hosue position")
					    p.ProximityPrompt.Enabled = false
						v.Visible = false
					end
				end
			end
		end
	end
end)

this is the gui:

this is the object(house):

it gives me an error that says

  22:52:22.649  LookVetcor is not a valid member of CFrame  -  Server - CloneHouse:19
``

That’s a mistypo oof

Replace

With

					   	clone:SetPrimaryPartCFrame(p:WaitForChild("HouseSpawnPart").CFrame + Vector3.new(0,7,0) , v.CFrame.LookVector)

another problem tho…:frowning_face: :frowning_face:

Only one house supposed to be clone …but every house that player owned is cloned…

Seems like it’s from 1 of your conditional checks, specifically in these lines:

Are you sure that Playerplcae is equal to 1 house individually…? It could also be because you’re using so much nested loops, so it keeps looping & looping throughout the entire time

I think sooo…try to look at this maybe somethings wrong

Screenshot (15)

also, ignore the Taken Values

there is 20 of them

1 Like

Can you check the properties to make sure that the Value isn’t equal to your name before you even start the simulation?

there a no Value …it an empty string(all of them)

That may be the thing though

If PlayerPlcae has its value changed when the ProximityPrompt gets activated, it might’ve set the value for all of them

local houses = game.ReplicatedStorage.House:GetChildren()
local pos = game.Workspace.PromptInterract.HouseOwning:GetChildren()
local event = game.ReplicatedStorage.Remotes.CloneHouseOne1

event.OnServerEvent:Connect(function(player)
	print("getting player from frame")
	local frame = player.PlayerGui:WaitForChild("HouseGui"):WaitForChild("HouseFrame").ScrollingFrame:GetChildren()
	for i , v in pairs(frame)do
		for _ , house in pairs(houses)do
			for k , p in pairs(pos)do
				  if v.Name == house.Name and v:WaitForChild("Name").Value == house.Name then
			        print("getting houses form frame")
                    print("This is equal to: "..p.PlayerPlcae.Value == player.Name, p.PlayerPlcae.Value, player.Name)
				    if p:WaitForChild("PlayerPlcae").Value == player.Name then
				        print("getting position house")
					    local clone = house:Clone()
					    print("cloning house for player")
					    clone.Parent = game.Workspace:WaitForChild(player.Name.."Stuff")
					   	print("set house parent")
					   	clone:SetPrimaryPartCFrame(p:WaitForChild("HouseSpawnPart").CFrame + Vector3.new(0,7,0) , v.CFrame.LookVetcor)
					   	print("set hosue position")
					    p.ProximityPrompt.Enabled = false
						v.Visible = false
					end
				end
			end
		end
	end
end)

I’d just recommend printing for that specific conditional check

the output says

 23:19:00.408  false EducatedPilot04 EducatedPilot04  -  Server - CloneHouse:13

what does false means??

False is basically saying that it’s not equal to what you checked

Are you sure that you didn’t confuse a StringValue with an ObjectValue though…? You should’ve gotten at least a couple of other prints

(PlayerPlcae) is string value,

also otuput is printing, no error at all

Can you show what every Output prints out then?

for some reason it prints many time

this is the problem

everything was cloned