I want to create a test place where parts duplicate fast (1-10 times per second) and their physics are executed by my PC and not the server. The parts then pile up and can be pushed away using an explosion.
The problem is that I’m not as advanced in scripting so I need help with writing a script for the cloning system. It has to be both fast and only on the client side, but all my knowledge doesn’t seem to work… The solutions that I have tried are different. Scripting of the cloning system inside a Script and LocalScript, using Instance.new, using both Part with ClickDetector and Button Gui… nothing did the expected result (create a part fast and on client side in workspace)
. This is the code that I used for cloning:
local Glass = game.ReplicatedStorage.Glass
script.Parent.MouseClick:Connect(function()
Glass:Clone().Parent = workspace
end)
local Glass = game.ReplicatedStorage.Glass
script.Parent.MouseClick:Connect(function()
while true do
Glass:Clone()
Glass.Parent = game.Workspace
wait()
end
end)
This should do what you are wanting, if you want an code to stop it, just tell me.
Well,thats true,but it would do instantly,which would mean in many parts being loaded at the same time,at the “same” speed.Dont need to correct me if i’am wrong.
local Glass = game.ReplicatedStorage.Glass
script.Parent.MouseClick:Connect(function()
while true do
>>>> Glass:Clone() --local cloned = Glass:Clone()
Glass.Parent = game.Workspace
wait()
end
end)
Which indicates that it will get the original part
I made this so you can turn it on and off like a water tap but it rains "Glass"
local Glass = game.ReplicatedStorage.Glass
local on = false
script.Parent.MouseClick:Connect(function()
if on then
on = false
else
local cloned = Glass:Clone()
cloned.Parent = game.workspace
on = true
end)
while on == true do
local cloned = Glass:Clone()
cloned.Parent = game.workspace
wait()
end
local Glass = game.ReplicatedStorage.Glass
script.Parent.MouseClick:Connect(function()
local AmountOfClones = 10 -- Change this to the amount of copies you want.
for i = 1, AmountOfClones do
Glass:Clone().Parent = workspace
wait(0.001) -- Change this number to how many seconds you want it to wait between making each clone. Or delete this line if you don't want it to wait at all.
end
end)
Your script is almost what I wanted to happen, but for some reason it didn’t work. Then I edited it to this:
local Glass = game.ReplicatedStorage.Glass
local on = false
script.Parent.MouseClick:Connect(function()
if on then on = false else
on = true
while on == true do
wait(0.1)
Glass:Clone().Parent = workspace
end
end
end)
Now it works and I need the last thing, making the part physics local instead of global. The reason why I want this is because the more global moving parts, the more internet sent and recieved. So I can have low internet flow and greater part physics with making this part flow local only.
You can store your remove event in replicated storage and the call script for it in server script service for when ever it’s functioned by the local script.
local script > StarterGui/Other but in player scripts Script(server) > ServerScriptService Remote Event > ReplicatedStorage
local script makes a remote event
local RemoteEvent= ReplicatedStorage:WaitForChild("remoteEvent")
---Button example;
local button = script.Parent.button
button.MouseButton1Click:Connect(function()
RemoteEvent:FireServer("duplicatePart", BrickColor.Green())
end
-------
server script checks the remote event
local ReplicatedStorage= game:GetService("ReplicatedStorage")
local remoteEvent= ReplicatedStorage:WaitForChild("remoteEvent")
local glass = game.ReplicatedStorage:WaitForChild("Glass")
local function duplicatePart(player, color)
local clonedGlass = glass:Clone()
clonedGlass.BrickColor = color
clonedGlass.Parent = game.Workspace
end
remoteEvent.OnServerEvent:Connect(duplicatePart)
I suggest using this method, if you want to create a gui button