local Cooldown = false
local explosion = script.Parent.Explosion
local debris = game:GetService("Debris")
script.Parent.Activated:Connect(function()
local player = script.Parent.Parent
if Cooldown == false then
Cooldown = true
local part = Instance.new("Part")
part.Position = player:GetPrimaryPartCFrame().Position
part.CFrame = player.HumanoidRootPart.CFrame
part.Anchored = true
part.CanCollide = false
part.Transparency = 0
part.Size = Vector3.new(1,1,1)
part.Parent = workspace
local lightingVFX = Instance.new("Part")
lightingVFX.Position = part.Position
lightingVFX.Material = Enum.Material.Neon
lightingVFX.Anchored = true
lightingVFX.CanCollide = false
lightingVFX.Size = Vector3.new(5,5,20)
lightingVFX.Color = Color3.fromRGB(255, 0, 4)
lightingVFX.Parent = workspace
for i = 1,10 do
player:SetPrimaryPartCFrame(player:GetPrimaryPartCFrame() * CFrame.new(Vector3.new(0,0,-30)))
task.wait(0.01)
end
local explosionClone = explosion:Clone()
explosionClone.Position = player.HumanoidRootPart.Position
explosionClone.Color = Color3.fromRGB(255, 0, 4)
part.CFrame = part.CFrame * CFrame.new(part.Position,explosionClone.Position)
lightingVFX.CFrame = part.CFrame + part.CFrame.LookVector * ((lightingVFX.Size.Z / 2) + (part.Size.Z / 2))
--lightingVFX.Size = Vector3.new(lightingVFX.Position,explosionClone.Position).Magnitude
debris:AddItem(lightingVFX,234567876543)
--part:Destroy()
explosionClone.Parent = workspace
explosionClone.Owner.Value = player.Name
explosionClone.Script.Enabled = true
wait(8)
Cooldown = false
end
end)
For context, this script is a tool. When a player uses the tool, their position will be changed according to the direction they are facing. After that is finished, a explosion will appear on the player’s new position, along with parts that are from the original position that serve as “Lighting” as extras.
For extra additional details, the extra part before lightingVFX
is used as a way to direct the lightingVFX
part through lookvector. I need it because I don’t want the part to increase in size twice (Basically, the lightingVFX
part is at the front of “Part” and increases in size accordingly to the distance the explosion is at with minimal detail possible. Essentially like a weldconstraint line, from a part to a part, with no overextended boundaries. That’s what I want).
Now, here’s the problem. While the parts where moving the player, creating the explosion works, the lighting visuals do not. I do not know how to make the part increase in size according to the from the distance of both lightingVFX
and the explosion’s position (How far apart they are separated each other, the part will increase in size to reach that position).
There’s also a side problem that I also need fixed and I do not know how to do so with just a part, other than a model. (part.CFrame = (part.CFrame * CFrame.new(part.Position,explosionClone.Position)
The part position changes in game and I do not know how to make it so that it stays in only one position while homing towards the player’s position. Although it does home towards the player’s position when using the tool, the part’s position changes in the process, which is a side problem I do not want and need the part to be somehow staying on the same position while homing towards the player’s new position.
These are all the problems. If anyone would like to help, please do! I’d greatly appreciate it.