I try to weld the hitbox to the bomb when i throw it but ever time I unanchor it just falls to the ground. I’ve tried setting the CFrame to the bomb but it doesn’t change to the updated CFrame.
local script
--// Servies
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
--// Instances
local player = game.Players.LocalPlayer
local Character = player.Character
local humanoid = Character.Humanoid
local animator = humanoid.Animator
local mouse = player:GetMouse()
local remote = game.ReplicatedStorage.Remotes:WaitForChild("SpiritBomb")
local face = require(game.ReplicatedStorage.Modules.FaceMouseModule)
local HumanoidRootPart = Character.HumanoidRootPart
local camera = workspace.CurrentCamera
local Charging = animator:LoadAnimation(RS.Assests.Animations.Charging)
local Bomb = RS.Assests.Effects.Spirit:Clone()
--// Modules
local VFXHandler = require(game.ReplicatedStorage.Modules.VFXHandler)
local soundmodule = require(game.ReplicatedStorage.Modules.SoundModule)
local face = require(game.ReplicatedStorage.Modules.FaceMouseModule)
local camshaker = require(RS.Modules.CameraShaker)
local RocksModule = require(RS.Modules.RocksModule)
local zc = require(RS.Modules.ZonitoCurves)
local VFXHelp = require(RS.Modules.VFXHelp)
local camShake = camshaker.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
camera.CFrame = camera.CFrame * shakeCFrame
end)
camShake:Start()
local function ColorCorrectionEffect(SaturationStart:Number, ContrastStart:Number, SaturationEnd:Number, ContrastEnd:Number, DelayTime:Number, Duration:Number)
--// Create a new ColorCorrectionEffect
local ColorCorrection = Instance.new('ColorCorrectionEffect')
ColorCorrection.Saturation = SaturationStart
ColorCorrection.Contrast = ContrastStart
ColorCorrection.Parent = game:GetService('Lighting')
--// Apply the effect and clean up after the specified duration
task.delay(DelayTime, function()
ColorCorrection.Saturation = SaturationEnd
ColorCorrection.Contrast = ContrastEnd
task.wait(Duration)
ColorCorrection:Destroy()
end)
end
--ColorCorrectionEffect(-1, -3, -1, 3, 0.04, 0.04)
local function EmitAll(Parent: Instance)
for _, v in Parent:GetChildren() do
if v:IsA("ParticleEmitter") and v:GetAttribute("EmitCount") then
task.delay(v:GetAttribute("EmitDelay"), function()
v:Emit(v:GetAttribute("EmitCount"))
end)
end
end
end
local function ToggleAll(Parent: Instance, Value: boolean, Switch: boolean, IncludeBeams: boolean)
for _, v in Parent:GetChildren() do
if v:IsA("ParticleEmitter") then
if Switch then
v.Enabled = not v.Enabled
else
v.Enabled = Value
end
end
if IncludeBeams and (v:IsA("Beam")) or (v:IsA("Trail")) then
if Switch then
v.Enabled = not v.Enabled
else
v.Enabled = Value
end
end
end
end
local function flyingrocks(HumanoidRootPart, IgnoreList)
VFXHandler.FlyingRocks{
i = 2; -- first loop
j = 5; -- nested loop
Offset = 10; -- radius from starting pos
Origin = HumanoidRootPart.Position; -- where to start
Filter = IgnoreList; -- filter raycast
Size = Vector2.new(1,3); -- size range random from 1,3
AxisRange = 80; -- velocity X and Z ranges from (-AxisRange,AxisRange)
Height = Vector2.new(50,60); -- velocity Y ranges from X,Y
Percent = 0.65; -- velocity * percent of nested loop
Duration = 2; -- duration of the debris rock
IterationDelay = 0; -- delay between each i loop
}
end
UIS.InputBegan:Connect(function(input,gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.Q then
local infnum = math.huge
local mousepos = mouse.Hit
local info = TweenInfo.new(
3,
Enum.EasingStyle.Sine,
Enum.EasingDirection.In,
0,
false,
0
)
local tween = TweenService:Create(HumanoidRootPart,info,{Position = HumanoidRootPart.Position + HumanoidRootPart.CFrame.UpVector * 57})
HumanoidRootPart.Anchored = true
tween:Play()
task.wait(3)
Charging:Play()
local info2 = TweenInfo.new(
7,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
Bomb.Parent = workspace.FX
Bomb.CFrame = HumanoidRootPart.CFrame * CFrame.new(0,57,0)
local tween2 = TweenService:Create(Bomb,info,{Size = Vector3.new(104, 104, 104)})
tween2:Play()
local info3 = TweenInfo.new(
3,
Enum.EasingStyle.Sine,
Enum.EasingDirection.In,
0,
false,
3
)
local tween3 = TweenService:Create(Bomb,info3,{CFrame = mouse.Hit})
tween3:Play()
task.wait(3.5)
remote:FireServer()
end
end)
server script
local remote = game.ReplicatedStorage.Remotes:WaitForChild("SpiritBomb")
local RS = game:GetService("ReplicatedStorage")
local bomb = RS.Assests.Effects.Spirit
remote.OnServerEvent:Connect(function(Player)
local Character = Player.Character
local Humanoid = Character:FindFirstChild("Humanoid")
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
local mouse = Player:GetMouse()
local function hitbox()
local hitbox1 = Instance.new("Part")
hitbox1.Shape = "Ball"
hitbox1.Size = Vector3.new(104, 104, 104)
hitbox1.CanCollide = false
hitbox1.Transparency = 0
hitbox1.Name = "Hitbox1"
hitbox1.Parent = workspace.FX
local weld = Instance.new("WeldConstraint")
weld.Part0 = hitbox1
weld.Part1 = bomb
weld.Parent = hitbox1
hitbox1.CFrame = HumanoidRootPart.CFrame * CFrame.new(0,125,0)
local params = OverlapParams.new()
params.FilterDescendantsInstances = {Character}
params.FilterType = Enum.RaycastFilterType.Exclude
local PartsTable = workspace:GetPartsInPart(hitbox1, params)
local DebounceTable = {}
for Index, Part in PartsTable do
if Part.Parent:FindFirstChild("Humanoid") and not table.find(DebounceTable, Part.Parent) then
table.insert(DebounceTable, Part.Parent)
local Character = Part.Parent
local Humanoid = Character:FindFirstChild("Humanoid")
Humanoid:TakeDamage(40)
end
end
table.clear(DebounceTable)
end
hitbox()
end)