So, im making a gun system like Isle and this is my 3 topic about it, uh
So, i need to get a part that gets cloned to the workspace, but if i get one i cant get the others cuz it will break the system, so how would i make it so that i can get every one that goes in workspace
idk if i explained this well cuz idk how to explain it
The script
local tool = script.Parent
local remote = tool:WaitForChild("OnShoot")
local shoot_part = tool:WaitForChild("FirePart")
local Attaches = game.ServerStorage:WaitForChild("Shoot")
local Shooting = false
tool.OnShoot.OnServerEvent:Connect(function(player, target)
local targetpart = target
if targetpart:IsA("BasePart") and targetpart.Parent:FindFirstChild("ZombieNoid") then
if not Shooting then
Shooting = true
local hu = targetpart.Parent:FindFirstChild("HumanoidRootPart")
Attaches:Clone().Parent = game.Workspace
wait(0.2)
local bullet = game.Workspace.Shoot
bullet.Attach1.Position = shoot_part.Position
bullet.Attach2.Position = hu.Position
wait(3)
Shooting = false
end
end
end)
You want to clone multiple parts? I guess it would be possible if you could somehow have them under something like a table or folder, then you could use a for loop, like this:
local partsTable = {part1,part2,part3}
for index,value in pairs(partsTable) do -- if this doesnt work try partsTable:GetCHildren(), i dont remember which it is :P
local clonePart = v:Clone()
end
i dont want to clone multiple parts, only one that clones to the workspace multiple times when a player uses the gun, for a gun system
Sorry if that sounded a bit mean i didnt find other way to say
Don’t worry about sounding aggressive, it’s my fault for repeatedly misinterpreting you!
So you want to clone one part multiple times? Could you confirm I got this right?
Edit: If so, you could just try this:
local count = 0
repeat
-- this is where youd clone the part
count+=1
until count == 5 -- this is how many times you want the script to run
local tool = script.Parent
local remote = tool:WaitForChild("OnShoot")
local shoot_part = tool:WaitForChild("FirePart")
local Attaches = game.ServerStorage:WaitForChild("Shoot")
local Shooting = false
tool.OnShoot.OnServerEvent:Connect(function(player, target)
local targetpart = target
if targetpart:IsA("BasePart") and targetpart.Parent:FindFirstChild("ZombieNoid") then
if not Shooting then
Shooting = true
local hu = targetpart.Parent:FindFirstChild("HumanoidRootPart")
Attaches:Clone().Parent = game.Workspace
workspace.ChildAdded:Connect(function(newChild)
if newChild.Name == "" then --some expected name
--do some code
end
end)
wait(0.2)
local bullet = game.Workspace.Shoot
bullet.Attach1.Position = shoot_part.Position
bullet.Attach2.Position = hu.Position
wait(3)
Shooting = false
end
end
end)
I’ve added it into the code, I believe this is where you want it although you may want it somewhere else.