What I want to do: I want to make a punching effect
Problem: It’s rotated the wrong way facing upwards
What I have tried: I looked into the dev forum, but couldn’t find anything
This is the main piece of code:
c = dmgPart.Touched:Connect(function(hit)
print(d, hitable)
if d == false and hitable == true and hit.Parent:FindFirstChild"Humanoid" then
c:Disconnect()
print("Passed the checks")
d = true
hitable = false
local eff = effectClass:CreateHeavyPunch(dmgPart)
local victimChar = hit.Parent
local victimHum = victimChar:FindFirstChild"Humanoid"
victimHum:TakeDamage(damage)
PunchSFX:Play()
--local victimPlayer = game.Players:GetPlayerFromCharacter(victimChar)
local victimStand = victimChar:FindFirstChildOfClass"Model"
if victimStand then
victimStand:Destroy()
end
--victimPlayer.StandEquipped.Value = false
print("Damaged")
loadedAnimation.Stopped:Wait()
effectClass.Destroy(eff)
d = false
end
end)
And this is the module script it’s referring to:
local effect = {}
function effect:CreateHit(part)
local clone = script.HitEffect:Clone()
clone:SetPrimaryPartCFrame(part.CFrame)
clone.Parent = part
return clone
end
function effect:CreateBarrage(part)
local clone = script.BarrageCollisionEffect:Clone()
clone:SetPrimaryPartCFrame(part.CFrame)
clone.Parent = part
return clone
end
function effect:CreateHeavyPunch(player, part)
local clone = script.StrongPunchEffect:Clone()
clone:SetPrimaryPartCFrame(part.CFrame)
clone.Parent = part
return clone
end
function effect.Destroy(effect)
effect:Destroy()
end
return effect
When changing the effect direction, you can do FirstCFrame * CFrame.new(your offset goes here). This would change the offset, you can make it opposite like CFrame.new(0, 0, -3).
The part I used to define the CFrame of the effect is welded to the right hand, which is slightly tilted during the animation. I just set the effect’s CFrame to LowerRightHand, and everything seems to work fine.
Main piece of code:
c = dmgPart.Touched:Connect(function(hit)
print(d, hitable)
if d == false and hitable == true and hit.Parent:FindFirstChild"Humanoid" then
c:Disconnect()
print("Passed the checks")
d = true
hitable = false
local eff = effectClass:CreateHeavyPunch(Stand.RightLowerArm)
local victimChar = hit.Parent
local victimHum = victimChar:FindFirstChild"Humanoid"
victimHum:TakeDamage(damage)
PunchSFX:Play()
--local victimPlayer = game.Players:GetPlayerFromCharacter(victimChar)
local victimStand = victimChar:FindFirstChildOfClass"Model"
if victimStand then
victimStand:Destroy()
end
--victimPlayer.StandEquipped.Value = false
print("Damaged")
loadedAnimation.Stopped:Wait()
wait(.5)
effectClass.Destroy(eff)
if tempPoints.Value >= 10 and Player.PowerPoint.Value < 10 then
Player.PowerPoint.Value += 1
tempPoints.Value = 0
end
tempPoints.Value+=1
d = false
end
end)
The module it’s referring to:
local effect = {}
function effect:CreateHit(part)
local clone = script.HitEffect:Clone()
clone:SetPrimaryPartCFrame(part.CFrame)
clone.Parent = part
return clone
end
function effect:CreateBarrage(part)
local clone = script.BarrageCollisionEffect:Clone()
clone:SetPrimaryPartCFrame(part.CFrame)
clone.Parent = part
return clone
end
function effect:CreateHeavyPunch(part)
local clone = script.StrongPunchEffect:Clone()
clone:SetPrimaryPartCFrame(part.CFrame)
clone.Parent = part
return clone
end
function effect.Destroy(effect)
effect:Destroy()
end
return effect