local tool = script.Parent
local fireEvent = tool:FindFirstChild(“fire”)
local deleteTime = 15
function spawnPart(pos, amount)
for i = 0,amount do
local partColor = BrickColor.random()
local part = Instance.new(“Part”)
part.Transparency = 1
part.Parent = workspace.parts
part.CFrame = pos
part.BrickColor = partColor
return part
end
end
fireEvent.OnServerEvent:Connect(function(player, pos)
local spawned = player.leaderstats.spawned
spawnPart(pos,2)
local part = spawnPart(pos,2)
spawned.Value = spawned.Value + 1
part.Transparency = 1
for i = 1, 10 do
wait(0.1)
part.Transparency = part.Transparency - 0.1
end
task.wait(deleteTime)
for i = 1, 10 do
wait(0.1)
part.Transparency = part.Transparency + 0.1
end
It’s seems you using loops to set a parts transparency. Try using Tweens also you only 1 return 1 part from the Spawn Part function. This might be what it looks like:
local tool = script.Parent
local fireEvent = tool:FindFirstChild("fire")
local deleteTime = 15
local TweenService = game:GetService("TweenService")
function spawnPart(pos, amount)
local Parts = {}
for i = 0, amount do
local partColor = BrickColor.random()
local part = Instance.new("Part")
part.Transparency = 1
part.Parent = workspace.parts
part.CFrame = pos
part.BrickColor = partColor
table.insert(Parts,part)
end
return Parts
end
fireEvent.OnServerEvent:Connect(function(player, pos)
local spawned = player.leaderstats.spawned
spawnPart(pos, 2)
local parts = spawnPart(pos, 2)
spawned.Value = spawned.Value + 1
parts[1].Transparency = 1
local transparencyGoal = 0
local transparencyInfo = TweenInfo.new(1, Enum.EasingStyle.Linear)
local transparencyTween = TweenService:Create(parts[1], transparencyInfo, { Transparency = transparencyGoal })
transparencyTween:Play()
transparencyTween.Completed:Wait() -- Wait for the tween to complete
task.wait(deleteTime)
transparencyGoal = 1
transparencyTween = TweenService:Create(parts[2], transparencyInfo, { Transparency = transparencyGoal })
transparencyTween:Play()
transparencyTween.Completed:Wait() -- Wait for the tween to complete
parts[1]:Destroy()
end)