I’m trying to make a block for my game, but the animation for the block isn’t stopping.
LocalScript:
local block = game.ReplicatedStorage.Block
local UIS = game:GetService("UserInputService")
local blockanim
local plr = game.Players.LocalPlayer
local char = script.Parent
local blocking = false
UIS.InputBegan:Connect(function(inp)
if inp.KeyCode == Enum.KeyCode.F then
local tool = char:FindFirstChildWhichIsA("Tool")
if tool.ItemClass.Value == "Weapon" then
if blocking == false then
local blockanim = tool:FindFirstChild("Block")
block:FireServer(blocking, tool)
blocking = true
wait(1)
block:FireServer(blocking, tool)
blocking = false
end
end
end
end)
ServerScript:
local block = game.ReplicatedStorage.Block
local blockanim
block.OnServerEvent:Connect(function(plr, blocking, tool)
local char = plr.Character
local hum = char.Humanoid
blockanim = hum:LoadAnimation(tool.Block)
if blocking == false then
local ff = Instance.new("ForceField", char)
ff.Name = "BlockFF"
blockanim:Play()
else
char:FindFirstChild("BlockFF"):Destroy()
blockanim:Stop()
end
end)
local block = game.ReplicatedStorage.Block
local UIS = game:GetService("UserInputService")
local blockanim
local plr = game.Players.LocalPlayer
local char = script.Parent
local blocking = false
UIS.InputBegan:Connect(function(inp)
if inp.KeyCode == Enum.KeyCode.F then
local tool = char:FindFirstChildWhichIsA("Tool")
if tool.ItemClass.Value == "Weapon" then
if blocking == false then
local blockanim = tool:FindFirstChild("Block")
blocking = true
block:FireServer(blocking, tool)
wait(1)
blocking = false
block:FireServer(blocking, tool)
end
end
end
end)
ServerScript:
local block = game.ReplicatedStorage.Block
local blockanim
block.OnServerEvent:Connect(function(plr, blocking, tool)
local char = plr.Character
local hum = char.Humanoid
blockanim = hum:LoadAnimation(tool.Block)
if blocking == true then
local ff = Instance.new("ForceField", char)
ff.Name = "BlockFF"
blockanim:Play()
else
if char:FindFirstChild("BlockFF") then
char:FindFirstChild("BlockFF"):Destroy()
blockanim:Stop()
end
end)
local block = game.ReplicatedStorage.Block
local UIS = game:GetService("UserInputService")
local blockanim
local plr = game.Players.LocalPlayer
local char = script.Parent
local blocking = false
UIS.InputBegan:Connect(function(inp)
if inp.KeyCode == Enum.KeyCode.F then
local tool = char:FindFirstChildWhichIsA("Tool")
if tool.ItemClass.Value == "Weapon" then
if blocking == false then
local blockanim = tool:FindFirstChild("Block")
blocking = true
block:FireServer(plr,blocking, tool)
wait(1)
blocking = false
block:FireServer(plr,blocking, tool)
end
end
end
end)