-
What do you want to achieve?
I’m trying to make a bomb attack that is similar to spirit bomb where after the character jumps up, a bomb starts charging then the bomb moves towards the mouse’s position when it was used. -
What is the issue?
When I fire the event from a local script, instead of giving the mouse’s hit CFrame it gives the player that used it instead which I find very confusing. -
What solutions have you tried so far?
I tried making the bomb’s function a seperate function then connecting it to the onserverevent of the remote event but that didn’t work either.
I use a tool firstly and then use a local script to activate the move when the tool is activated through a Remote Event. After that the script does all the bomb’s effects and projectiles and stuff.
Local Script
--Variables--
local Tool = script.Parent
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Events = Tool:WaitForChild("Events")
local Animations = Tool:WaitForChild("Animations")
local Damage = Tool.Damage
local Cooldown = Tool.Cooldown
local Ready = true
--Functions--
local AttackEvent = Events:WaitForChild("Attack")
local EquipEvent = Events:WaitForChild("Equip")
local UnequipEvent = Events:WaitForChild("Unequip")
script.Parent.Activated:Connect(function()
print("run")
local Mouse = Player:GetMouse()
local MouseHit = Mouse.Hit
if Ready == true then
Ready = false
AttackEvent:FireServer(Player, MouseHit)
for i = Cooldown.Value,0,-0.1 do
Tool.Name = math.floor(i*10)/10
--print(i)
task.wait(0.1)
end
Tool.Name = "Fire Bomb"
Ready = true
end
end)
Script (The Attacking Function)
local function Attacking(plr:Player, MouseHit)
print(plr,MouseHit)
local Character = plr.Character
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local Shockwave = Effects:WaitForChild("FireballShockwave"):Clone()
local Fireball = Effects:WaitForChild("Fireball"):Clone()
local JumpTable = {
CFrame = Character:WaitForChild("HumanoidRootPart").CFrame + Vector3.new(0,20,0)
}
local JumpTween = TweenService:Create(Character:WaitForChild("HumanoidRootPart"),TweenInfo.new(0.6,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false),JumpTable)
Character:WaitForChild("HumanoidRootPart").Anchored = true
JumpTween:Play()
Attack(plr)
TheParams.FilterDescendantsInstances = {Character}
Overlap.FilterDescendantsInstances = {Character}
wait(2)
Effects.Firebomb.Size = Vector3.new(50,50,50)
Sounds.Fireball:Play()
Caster:Fire(Character:WaitForChild("HumanoidRootPart").Position + Vector3.new(0,45,0),MouseHit.LookVector,90,Behaviour)
task.wait(1)
Character:WaitForChild("HumanoidRootPart").Anchored = false
Caster.RayHit:Connect(function(Caster,Result,SegmentVelocity,CosmeticBullet)
if Result.Instance.Parent:FindFirstChildOfClass("Humanoid") and Ready == true then
Ready = false
Sounds.Explosion:Play()
Result.Instance.Parent:FindFirstChildOfClass("Humanoid"):TakeDamage(Damage.Value)
local ExplosionTween = TweenService:Create(CosmeticBullet,TweenInfo.new(0.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false),{Size = Vector3.new(25,25,25);Transparency = 1})
ExplosionTween:Play()
Boom(CosmeticBullet.Position)
Debris:AddItem(CosmeticBullet,2)
task.wait(2)
Ready = true
end
end)
end
AttackEvent.OnServerEvent:Connect(Attacking)