Doing this again since the last answer failed. So I'm making this RC car system, controlled by a tool. When the player clicks the button in the GUI, it fires a RemoteEvent from a local script. In a server script, it responds to that RemoteEvent and regenerates it. But the problem is that when there's more than 1 player, the script causes massive duplication. I still have no idea why this is happening, or what is causing it.
SERVER:
model = game.Workspace.Lowenherz -- Change "Compressor" to the name of your model. new = model:clone() enabled = true game.ReplicatedStorage.LowenherzRemotes.RegenLowenherz.OnServerEvent:Connect(function() if enabled then model:Destroy() script.Parent["Car Ignition Startup"]:Play() enabled = false wait(0.3) -- This is how long it will take to regen model = new:clone() model.Parent = game.Workspace wait(5) -- This is how long it will take for the regen button to be enabled after being used enabled = true end end)
LOCAL:
script.Parent.MouseButton1Click:connect(function() game.ReplicatedStorage.LowenherzRemotes.RegenLowenherz:FireServer() end)
Hello!
Since the ServerScript
is inside the GUIButton
, It will create one Server script for each PlayerGui. Means for example: If 5 Players are inside the Game, It will be run 5 times (The OnServerEvent gets connected 5 Times), Which causes Massive duplication. (Because the Serverscript got duplicated multiple times).
Try putting the Serverscript inside Serverscriptservice
and see if that helps.