Its my first time making an anime skill, and it was going great, had a bit of problems but troubleshooted them. One which i cannot troubleshoot is, when the player animation is playing, a hitbox I have made for the part has not been registering part.Touched or TouchingObjects, I have tried to make the hitbox in so many possible ways, that im not sure if its because of the vfx.
Here is a screenshot:
It clones the hitbox with a script inside of it that when touched it kill, which works normally, but when the player animation is playing, it doesnt register it. I have tried MANY more different ways, and all of them had the same problem.
local PurpleClone = Purple:Clone()
PurpleClone.Parent = Character
PurpleClone.Name = "PurpleClone"
PurpleClone.Position = Character1 + Vector3.new(0,7,-15)
local hitbox = game.Workspace.CloneFolder.Hitbox:Clone()
hitbox.Parent = PurpleClone.Parent
hitbox.Position = PurpleClone.Position
local function PurpleHitBox(player)
print(player)
local humanoid = player.Character and player.Character:FindFirstChildOfClass("Humanoid")
if humanoid then
print("Health down")
humanoid.Health = 1
end
end
local endPos2 = Character1 + Vector3.new(0, 0, -1000)
local tweenInfo2 = TweenInfo.new(4, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local tweenGoal2 = {}
tweenGoal2.Position = endPos2
local tween2 = TweenService:Create(PurpleClone, tweenInfo2, tweenGoal2)
local function startMovement2()
tween2:Play()
end
task.wait(4)
BlueClone:Destroy()
RedClone:Destroy()
startMovement2()
while true do
task.wait()
hitbox.Position = PurpleClone.Position
hitbox.Touched:Connect(function(other)
local humanoid = other.Parent:WaitForChild("Humanoid")
if humanoid then
print("Health down")
humanoid:TakeDamage(100)
else
end
end)
end
task.wait(7)
PurpleClone:Destroy()
end)
I have also implemented Part.Touch into the main part, but it didnt work either!
Pleas help.
You’re cloning the parts individually, you need to weld them together
Edit, you’re using a more complicated way, just give me 5 minutes so I can reply
hey! im a pretty new scripter myself but ill try to offer some advice on what u got so far.
i could be wrong ab this but u can change this from:
local humanoid = player.Character and player.Character:FindFirstChildOfClass("Humanoid")
to:
local humanoid = player.Character:FindFirstChild("Humanoid") or player.Character:FindFirstChildOfClass("Humanoid")
next thing is, u can use one of the runservice events such as renderstepped
instead of while true do
, i think it works better in terms of performance. (less lag i think idk)
so like this:
RunService.RenderStepped:Connect(function()
task.wait()
hitbox.Position = PurpleClone.Position
hitbox.Touched:Connect(function(other)
local humanoid = other.Parent:WaitForChild("Humanoid")
if humanoid then
print("Health down")
humanoid:TakeDamage(100)
else
end
end)
end)
in terms of ur animation do u mean tween or an actually player animation that ur having trouble with? i kind of find it hard to grasp what ur trying to do.
Would it be possible to send the full script?
Client:
local Tool = script.Parent
local Anim = Tool.Animation
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local AnimTrack = Humanoid:LoadAnimation(Anim)
local Playing = false
local Remote= game.ReplicatedStorage.ToServer
Tool.Activated:Connect(function()
Playing = true
AnimTrack:Play()
Remote:FireServer()
if Playing == true then
script.Parent.Enabled = false
Character:WaitForChild("HumanoidRootPart").Anchored = true
else
script.Parent.Enabled = true
Character:WaitForChild("HumanoidRootPart").Anchored = false
end
AnimTrack.Stopped:Connect(function()
script.Parent.Enabled = true
Playing = false
Character:WaitForChild("HumanoidRootPart").Anchored = false
end)
end)
Server:
local Remote = game.ReplicatedStorage.ToServer
local VFXFolder = game.ReplicatedStorage.VFX
local Blue = VFXFolder.Blue
local Red = VFXFolder.Red
local Purple = VFXFolder.Purple
local TweenService = game:GetService("TweenService")
Remote.OnServerEvent:Connect(function(player)
local newff = Instance.new("ForceField")
newff.Parent = player.Character
------------------------------------------------
local Character = player.Character
local Character1 = player.Character:WaitForChild("HumanoidRootPart").Position
print("Got")
task.wait(4)
local RedClone = Red:Clone()
RedClone.Parent = Character
RedClone.Name = "RedClone"
RedClone.Position = Character1 + Vector3.new(25, 2, -13)
local OnStartRed = RedClone.OnStart
local function emit1()
OnStartRed.BlackOnTop:Emit(1)
OnStartRed.D:Emit(1)
OnStartRed.DB:Emit(1)
OnStartRed.DBL:Emit(1)
OnStartRed.DL:Emit(1)
OnStartRed.Glow:Emit(1)
OnStartRed.GlowM:Emit(1)
OnStartRed.Main1:Emit(1)
OnStartRed.MainBlack1:Emit(1)
OnStartRed.S:Emit(1)
end
-- Move red smoothly using TweenService
local endPos = Character1 + Vector3.new(0, 2, -13)
local tweenInfo = TweenInfo.new(2.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local tweenGoal = {}
tweenGoal.Position = endPos
local tween = TweenService:Create(RedClone, tweenInfo, tweenGoal)
-- Function to start the movement and emit particles after a short delay
local function startMovement()
tween:Play()
end
-- Start the movement
task.wait(0.1)
emit1()
task.wait(0.1)
task.wait(0.8)
startMovement()
-----------------------------------------------
print("Blue")
local BlueClone = Blue:Clone()
local BlueCloneChildren = BlueClone.OnStart:GetChildren()
BlueClone.Parent = Character
BlueClone.Name = "BlueClone"
BlueClone.Position = Character1 + Vector3.new(-25, 2, -13)
local OnStartBlue = BlueClone.OnStart
local function emit()
OnStartBlue.BlackOnTop:Emit(1)
OnStartBlue.D:Emit(1)
OnStartBlue.DB:Emit(1)
OnStartBlue.DBL:Emit(1)
OnStartBlue.DL:Emit(1)
OnStartBlue.Glow:Emit(1)
OnStartBlue.GlowM:Emit(1)
OnStartBlue.Main1:Emit(1)
OnStartBlue.MainBlack1:Emit(1)
OnStartBlue.S:Emit(1)
end
local endPos1 = Character1 + Vector3.new(0, 2, -13)
local tweenInfo1 = TweenInfo.new(2.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local tweenGoal1 = {}
tweenGoal1.Position = endPos1
local tween1 = TweenService:Create(BlueClone, tweenInfo1, tweenGoal1)
-- Function to start the movement and emit particles after a short delay
local function startMovement1()
tween1:Play()
end
task.wait(0.1)
emit()
task.wait(0.1)
startMovement1()
task.wait(1.8)
-------------------------------------------------------------------------
local function destroysmoothlyblue()
BlueClone.Crescents.Enabled = false
BlueClone.Darklightning.Enabled = false
BlueClone.Dots.Enabled = false
BlueClone.Dust.Enabled = false
BlueClone.Dust2.Enabled = false
BlueClone.ParticleEmitter.Enabled = false
BlueClone.Trace.Enabled = false
BlueClone.Trace1.Enabled = false
BlueClone.lightning.Enabled = false
BlueClone.Attachment2.ImpT.Enabled = false
BlueClone.Attachment3.Imp.Enabled = false
BlueClone.Attachment3.ImpT_In.Enabled = false
BlueClone.Attachment3.ParticleEmitter.Enabled = false
BlueClone.Attachment4.GlowG.Enabled = false
end
local function destroysmoothlyred()
RedClone.Crescents.Enabled = false
RedClone.Darklightning.Enabled = false
RedClone.Dots.Enabled = false
RedClone.Dust.Enabled = false
RedClone.Dust2.Enabled = false
RedClone.ParticleEmitter.Enabled = false
RedClone.Trace.Enabled = false
RedClone.Trace1.Enabled = false
RedClone.lightning.Enabled = false
RedClone.Attachment2.ImpT.Enabled = false
RedClone.Attachment3.Imp.Enabled = false
RedClone.Attachment3.ImpT_In.Enabled = false
RedClone.Attachment3.ParticleEmitter.Enabled = false
RedClone.Attachment4.GlowG.Enabled = false
end
destroysmoothlyred()
destroysmoothlyblue()
local PurpleClone = Purple:Clone()
PurpleClone.Parent = Character
PurpleClone.Name = "PurpleClone"
PurpleClone.Position = Character1 + Vector3.new(0,7,-15)
local hitbox = game.Workspace.CloneFolder.Hitbox:Clone()
hitbox.Parent = PurpleClone.Parent
hitbox.Position = PurpleClone.Position
local function PurpleHitBox(player)
print(player)
local humanoid = player.Character and player.Character:FindFirstChildOfClass("Humanoid")
if humanoid then
print("Health down")
humanoid.Health = 1
end
end
local endPos2 = Character1 + Vector3.new(0, 0, -1000)
local tweenInfo2 = TweenInfo.new(4, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local tweenGoal2 = {}
tweenGoal2.Position = endPos2
local tween2 = TweenService:Create(PurpleClone, tweenInfo2, tweenGoal2)
local function startMovement2()
tween2:Play()
end
task.wait(4)
BlueClone:Destroy()
RedClone:Destroy()
startMovement2()
while true do
task.wait()
hitbox.Position = PurpleClone.Position
hitbox.Touched:Connect(function(other)
local humanoid = other.Parent:WaitForChild("Humanoid")
if humanoid then
print("Health down")
humanoid:TakeDamage(100)
else
end
end)
end
task.wait(7)
PurpleClone:Destroy()
end)
When a player animation is playing (Not tween), the hitbox on a currently tweening object is not working, only after it stops tweening. I tried what you said in your script, didnt really change anything.
1 Like
I would really like to, but the thing is i have very little knowledge about it even though i watched countless tutorials. Im currently experimenting with welds, but I didnt make anything too impressive yet.
its like a fireball right?
couldn’t u just do like this for welding the hitbox to the purpleclone (if thats what ur doing)
local weld:Weld = Instance.new("Weld", PurpleClone)
weld.Part0 = hitbox
weld.Part1 = PurpleClone
Close, its hollow purple. Yes, you just made me realize i could weld it, but not sure if it would solve the problem. Ill try it in the morning and let you know.
I don’t have the model, so this is the best I can do, sorry
This is the server script, I only edited the end (you just have to copy paste)
If it doesn’t work, try to check the part’s properties (CanTouch should be enabled)
local Remote = game.ReplicatedStorage.ToServer
local VFXFolder = game.ReplicatedStorage.VFX
local Blue = VFXFolder.Blue
local Red = VFXFolder.Red
local Purple = VFXFolder.Purple
local TweenService = game:GetService("TweenService")
Remote.OnServerEvent:Connect(function(player)
local newff = Instance.new("ForceField")
newff.Parent = player.Character
------------------------------------------------
local Character = player.Character
local Character1 = player.Character:WaitForChild("HumanoidRootPart").Position
print("Got")
task.wait(4)
local RedClone = Red:Clone()
RedClone.Parent = Character
RedClone.Name = "RedClone"
RedClone.Position = Character1 + Vector3.new(25, 2, -13)
local OnStartRed = RedClone.OnStart
local function emit1()
OnStartRed.BlackOnTop:Emit(1)
OnStartRed.D:Emit(1)
OnStartRed.DB:Emit(1)
OnStartRed.DBL:Emit(1)
OnStartRed.DL:Emit(1)
OnStartRed.Glow:Emit(1)
OnStartRed.GlowM:Emit(1)
OnStartRed.Main1:Emit(1)
OnStartRed.MainBlack1:Emit(1)
OnStartRed.S:Emit(1)
end
-- Move red smoothly using TweenService
local endPos = Character1 + Vector3.new(0, 2, -13)
local tweenInfo = TweenInfo.new(2.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local tweenGoal = {}
tweenGoal.Position = endPos
local tween = TweenService:Create(RedClone, tweenInfo, tweenGoal)
-- Function to start the movement and emit particles after a short delay
local function startMovement()
tween:Play()
end
-- Start the movement
task.wait(0.1)
emit1()
task.wait(0.1)
task.wait(0.8)
startMovement()
-----------------------------------------------
print("Blue")
local BlueClone = Blue:Clone()
local BlueCloneChildren = BlueClone.OnStart:GetChildren()
BlueClone.Parent = Character
BlueClone.Name = "BlueClone"
BlueClone.Position = Character1 + Vector3.new(-25, 2, -13)
local OnStartBlue = BlueClone.OnStart
local function emit()
OnStartBlue.BlackOnTop:Emit(1)
OnStartBlue.D:Emit(1)
OnStartBlue.DB:Emit(1)
OnStartBlue.DBL:Emit(1)
OnStartBlue.DL:Emit(1)
OnStartBlue.Glow:Emit(1)
OnStartBlue.GlowM:Emit(1)
OnStartBlue.Main1:Emit(1)
OnStartBlue.MainBlack1:Emit(1)
OnStartBlue.S:Emit(1)
end
local endPos1 = Character1 + Vector3.new(0, 2, -13)
local tweenInfo1 = TweenInfo.new(2.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local tweenGoal1 = {}
tweenGoal1.Position = endPos1
local tween1 = TweenService:Create(BlueClone, tweenInfo1, tweenGoal1)
-- Function to start the movement and emit particles after a short delay
local function startMovement1()
tween1:Play()
end
task.wait(0.1)
emit()
task.wait(0.1)
startMovement1()
task.wait(1.8)
-------------------------------------------------------------------------
local function destroysmoothlyblue()
BlueClone.Crescents.Enabled = false
BlueClone.Darklightning.Enabled = false
BlueClone.Dots.Enabled = false
BlueClone.Dust.Enabled = false
BlueClone.Dust2.Enabled = false
BlueClone.ParticleEmitter.Enabled = false
BlueClone.Trace.Enabled = false
BlueClone.Trace1.Enabled = false
BlueClone.lightning.Enabled = false
BlueClone.Attachment2.ImpT.Enabled = false
BlueClone.Attachment3.Imp.Enabled = false
BlueClone.Attachment3.ImpT_In.Enabled = false
BlueClone.Attachment3.ParticleEmitter.Enabled = false
BlueClone.Attachment4.GlowG.Enabled = false
end
local function destroysmoothlyred()
RedClone.Crescents.Enabled = false
RedClone.Darklightning.Enabled = false
RedClone.Dots.Enabled = false
RedClone.Dust.Enabled = false
RedClone.Dust2.Enabled = false
RedClone.ParticleEmitter.Enabled = false
RedClone.Trace.Enabled = false
RedClone.Trace1.Enabled = false
RedClone.lightning.Enabled = false
RedClone.Attachment2.ImpT.Enabled = false
RedClone.Attachment3.Imp.Enabled = false
RedClone.Attachment3.ImpT_In.Enabled = false
RedClone.Attachment3.ParticleEmitter.Enabled = false
RedClone.Attachment4.GlowG.Enabled = false
end
destroysmoothlyred()
destroysmoothlyblue()
local PurpleClone = Purple:Clone()
PurpleClone.Parent = Character
PurpleClone.Name = "PurpleClone"
PurpleClone.Position = Character1 + Vector3.new(0,7,-15)
local hitbox = game.Workspace.CloneFolder.Hitbox:Clone()
hitbox.Parent = PurpleClone.Parent
--------------------------- EDITED PART HERE -------------------------------------
local weld = Instance.new("Weld")
weld.Parent = PurpleClone
hitbox.CFrame = PurpleClone.CFrame
weld.Part0 = PurpleClone
weld.Part1 = hitbox
hitbox.CanTouch = true
hitbox.Touched:Connect(function(other)
if other.Parent:FindFirstChild("Humanoid") then
local hum = other.Parent:FindFirstChild("Humanoid")
hum:TakeDamage(100)
end
end)
---------------------------------------------------------------------------------------------
local function PurpleHitBox(player)
print(player)
local humanoid = player.Character and player.Character:FindFirstChildOfClass("Humanoid")
if humanoid then
print("Health down")
humanoid.Health = 1
end
end
local endPos2 = Character1 + Vector3.new(0, 0, -1000)
local tweenInfo2 = TweenInfo.new(4, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local tweenGoal2 = {}
tweenGoal2.Position = endPos2
local tween2 = TweenService:Create(PurpleClone, tweenInfo2, tweenGoal2)
local function startMovement2()
tween2:Play()
end
task.wait(4)
BlueClone:Destroy()
RedClone:Destroy()
startMovement2()
-------------------MOVED TO ANOTHER PLACE----------------------------
task.wait(7)
PurpleClone:Destroy()
end)
Hello! I appreaciate your answer, though the problem has been solved. In my first version of trying to make a hitbox, I wanted to make just PurpleClone.Touched event, which did not work. Later, I found out I forgot to unanchor the Purple, which was causing it to not register the .Touched event, something else was blocking it from working too but I solved it too. Regardless, thanks for your help.
1 Like
Oh lol, alright! Well have fun developing your game! I hope you the best!
1 Like