When two players use this code, it only clones the part once and the scripts both use that same part for their needs. Does anyone know why this would happen?
Local script in StarterPlayerScripts:
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Mouse = LocalPlayer:GetMouse()
local RepStorage = game:GetService("ReplicatedStorage")
local DeletePart = RepStorage.DeletePart -- remote event
local UIS = game:GetService("UserInputService")
print("1")
UIS.InputBegan:Connect(function(input)
local Hitposition = Mouse.Hit
print("2")
if input.KeyCode == Enum.KeyCode.R then
print("R Pressed")
DeletePart:FireServer(Hitposition)
end
end)
Normal script in ServerScriptService:
local RepStorage = game:GetService("ReplicatedStorage")
local DeletePart = RepStorage.DeletePart
local Cube = RepStorage.Cube:Clone()
local Cooldown = {}
local ExploP = RepStorage.WhiteExplosion -- particles
DeletePart.OnServerEvent:Connect(function(Player, Position)
if Cooldown[Player.name] then return warn(Player.Name.." is on cooldown")end
Cooldown[Player.Name] = os.time
Cube.Name = string.format("%s part", tostring (Player.name))
Cube.Parent = game.Workspace
Cube.CFrame = Position
Cube.Anchored = false
wait()
Cube.Anchored = true
for i = 15,1,-1 do
Cube.Size = Vector3.new(i+5,i+5,i+5)
wait(.5)
end
ExploP.Parent = Cube
wait(1)
ExploP.Parent = RepStorage
Cube.Parent = RepStorage
delay(2,function() -- 2 = cooldown time after cube over
Cooldown[Player.Name] = nil
end)
end)
