You can write your topic however you want, but you need to answer these questions:
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.
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
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.
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)
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
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