Throughout this attack the player is supposed to be able to click "T" then it plays one animation and throughout that it's able to damage players. After that animation is finished it plays one out of two potential animations next, although once I made it so an animation plays before the two everything broke. Any help?
LocalScript that finds the key is pressed. (StarterCharacterScripts)
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local punchEvent = ReplicatedStorage:WaitForChild("PunchEvent")
local ready = true
local function punch(inputObject, gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.T and ready then
punchEvent:FireServer()
ready = false
wait(0.5)
ready = true
end
end
UserInputService.InputBegan:Connect(punch)
Script that plays animations. (ServerScriptService)
math.randomseed(tick())
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local punchEvent = Instance.new("RemoteEvent", ReplicatedStorage)
punchEvent.Name = "PunchEvent"
local animations = {2867395453, 2867339668}
local animationp = {2867339187}
local function onPunchFired(plr)
local char = game.Workspace:FindFirstChild(plr.Name)
local humanoid = char.Humanoid
local animation = Instance.new("Animation")
local animation2 = Instance.new("Animation")
local picked = math.random(1, #animations)
animation.AnimationId = "http://roblox.com/asset/?id="..animations[picked]
animation2.AnimationId = "http://roblox.com/asset/?id="..animationp
local animTrack = humanoid:LoadAnimation(animation2)
local animTrack2 = humanoid:LoadAnimation(animation)
animTrack:Play()
local dmgScript = script.DmgScript:Clone()
dmgScript.Parent = char.Blast
dmgScript.Disabled = false
wait(0.35)
dmgScript:Destroy()
animTrack:Stop()
animTrack2:Play()
wait(0.45)
animTrack2:Stop()
end
punchEvent.OnServerEvent:Connect(onPunchFired)
Script that enabled the player's ability to do damage. (Child of Previous Script)
script.Parent.Touched:Connect(function(hit)
local char = hit.Parent
local hum = char:FindFirstChild("Humanoid")
if hum and char.Name ~= script.Parent.Parent.Name then
hum.Health = hum.Health - script.Dmg.Value
script.Disabled = true
wait(0.5)
script.Disabled = false
end
end)

2 comments
I... honestly don't think you should run animations on the server. animations on the client replicate you know
Makes sense I'll give it a try