My placement system places hundreds of models

Hello i am making a placement system but when i place the model it places hundreds of models.

The problem is with the while loop. Because the while loop is too fast the script invokes the server more than one. Here is a basic example(It it not the script it is just an example):

while task.wait() do
if Placed == true then break end
...(Some raycast stuff)
game.UserInputService.InputEnded:Connect(function(input,pros)
print(raycast.Instance.ClassName)
if input.KeyCode == Enum.KeyCode.E and raycast.Instance:IsA("Terrain") then
Placed=true
Copy:Destroy() -The model that i copied
game.ReplicatedStorage.Builderman.PlaceFunction:InvokeServer(Copy.WorldPivot,v.Name)
end

--It can be little confusing beacuse i shortened the script.
1 Like

I don’t know if the people here will be able to help you, try moving this to #help-and-feedback:scripting-support

1 Like