-
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.
-
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”.
-
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)