Hello, so i’ve made a attack system for my game. The client detects the inputs and fires an event to the server, who will then deal the damage and stuff, etc. The problems are :
-1st, The Bam/Pow thingy effect when the player hits another player/humanoid doesn’t face the player, i don’t really know how to make it work tho.
-2nd, the “elseif not Enemy” part of the code (which is supposed to check if the player is hitting a simple part like a wall instead of a humanoid) doesn’t run at all, it doesn’t even print anything.
Server Script
local function onAttackEvent(Player, ATK_Num, Hit_SFX, Fail_SFX, Woosh_SFX)
Woosh_SFX:Play()
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local Hum_Root = Character:WaitForChild("HumanoidRootPart")
----------------------------------------------------
local Parameters = RaycastParams.new()
Parameters.FilterType = Enum.RaycastFilterType.Exclude
Parameters.FilterDescendantsInstances = {Character}
----------------------------------------------------
local Origin = Hum_Root.Position
local Direction = Hum_Root.CFrame.LookVector * 5
local Result = workspace:Raycast(Origin, Direction, Parameters)
----------------------------------------------------
if Result then
local Part = Result.Instance
local Enemy = Part.Parent:FindFirstChild("Humanoid") or Part.Parent.Parent:FindFirstChild("Humanoid")
----------------------------------------------------
if Enemy and Enemy:GetState() ~= Enum.HumanoidStateType.Dead then
Hit_SFX.PlaybackSpeed = math.random(9, 11)/10
Hit_SFX:Play()
if ATK_Num == 1 then
Enemy:TakeDamage(math.random(2, 4))
local Blow_FX = Effects_FLDR.Blow:Clone()
Blow_FX.Parent = workspace
Blow_FX.Position = Character:WaitForChild("LeftHand").Position
Tween_SVC:Create(Blow_FX, TweenInfo.new(0.25, Enum.EasingStyle.Linear, Enum.EasingDirection.In), {Size = Vector3.new(4, 0.25, 4), Transparency = 1}):Play()
task.wait(0.5)
Blow_FX:Destroy()
elseif ATK_Num == 2 then
Enemy:TakeDamage(math.random(4, 6))
local Blow_FX = Effects_FLDR.Blow:Clone()
Blow_FX.Parent = workspace
Blow_FX.Orientation = Hum_Root.Orientation - Vector3.new(0, 180, 0)
Blow_FX.Position = Character:WaitForChild("RightHand").Position
Tween_SVC:Create(Blow_FX, TweenInfo.new(0.25, Enum.EasingStyle.Linear, Enum.EasingDirection.In), {Size = Vector3.new(4, 0.25, 4), Transparency = 1}):Play()
task.wait(0.5)
Blow_FX:Destroy()
elseif ATK_Num == 3 then
Enemy:TakeDamage(math.random(6, 8))
local Blow_FX = Effects_FLDR.Blow:Clone()
Blow_FX.Parent = workspace
Blow_FX.Orientation = Hum_Root.Orientation - Vector3.new(0, 180, 0)
Blow_FX.Position = Character:WaitForChild("RightFoot").Position
Tween_SVC:Create(Blow_FX, TweenInfo.new(0.25, Enum.EasingStyle.Linear, Enum.EasingDirection.In), {Size = Vector3.new(4, 0.25, 4), Transparency = 1}):Play()
task.wait(0.5)
Blow_FX:Destroy()
end
elseif Enemy == nil then
print("f")
Fail_SFX.PlaybackSpeed = math.random(9, 11)/10
Fail_SFX:Play()
end
end
end
Here is an illustration of how i want the “pow” effect to appear :
But instead it appears in it’s original orientation regardless of where the player is.