Server Script cloning models per player

  1. What do you want to achieve? For every player in the server, the server script clones a model per amount of player in the server. For example, if there are 3 players in a server, there will be 3 models. I would like it so it only clones it once when a player press the “F” key.

  2. What is the issue?
    In the screenshot, there are two players. Since there are two players, two models have been cloned despite only one player pressing “F”.

  3. What solutions have you tried so far? Unfortunately, I could not find any solutions that matches what I am looking for. Perhaps I haven’t been searching hard enough, and that would be my fault.

Here is the script:

local rStorage = game:GetService("ReplicatedStorage")
local event = rStorage.throwStuff
local bindableEvent = game:GetService("ServerStorage").Event
local tween = game:GetService("TweenService")

local tweeninfo = TweenInfo.new(
	.5,
	Enum.EasingStyle.Quint,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)


event.OnServerEvent:Connect(function(a, b, c)
	local plrName = tostring(a)
	local bomb = game.Workspace[plrName.."'s Bomb"].BasicBomb.Handle
	local bombPos = bomb.Position
	local distance = (bombPos - c).Magnitude
	if distance <= 75 then
		local newBomb = rStorage.BombStorage.theBomb:Clone()
		newBomb.Parent = workspace
		newBomb.Position = bombPos
		local goal = {
			
			Position = c
			
		}
		
		local bruh = tween:Create(newBomb, tweeninfo, goal)
		
		bruh:Play()
		bruh.Completed:Connect(function()
			bindableEvent:Fire(54765672837823802458)
		end)
		print("Distance: ", distance)
		print(a, bombPos)
	else
		print("long distance")
	end
end)

Try to add a debounce to your script, maybe the reason the bomb is duped more then once is because it receives 2 event signals instead of 1

I’ve solved it.

I placed the remote event in the local script and called that one instead.

Previously, I called a remote event in replicated storage which seemed to be the issue. If you have the same issue, please be mindful of where the event is called.

Good luck to everyone!