clip:
not completely needed to fix but an error pops up everytime which is a little irritating. just want to know why the other players are taken account of in the local script. The other local scripts in my game which are relatively similar do not have the same issues.
code:
local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local IsBlocking = Character:WaitForChild("IsBlocking")
local IsAttacking = Character:WaitForChild("IsAttacking")
local IsRunning = Character:WaitForChild("IsRunning")
local IsStun = Character:WaitForChild("IsStun")
local Animations = {
["anim1"] = 'rbxassetid://16083866545';
["anim2"] = 'rbxassetid://16083845444';
["spoonanim1"] = 'rbxassetid://16599449516';
["spoonanim2"] = 'rbxassetid://16599443369';
["axeanim1"] = 'rbxassetid://16821575332';
["axeanim2"] = 'rbxassetid://16821572773';
["rifleanim1"] = 'rbxassetid://97809881954323';
["rifleanim2"] = 'rbxassetid://108838492293709';
["knifeanim1"] = 'rbxassetid://114552893498450';
["knifeanim2"] = 'rbxassetid://131951576912120';
["spearanim1"] = 'rbxassetid://16821606775';
["spearanim2"] = 'rbxassetid://16821616888';
["swordanim1"] = 'rbxassetid://127615950687557';
["swordanim2"] = 'rbxassetid://111994683861193';
["timeanim1"] = 'rbxassetid://96964693020339';
["timeanim2"] = 'rbxassetid://127233903951731';
}
for i,v in pairs(Animations) do
local Anim = Instance.new("Animation")
Anim.AnimationId = v
Anim = Humanoid:LoadAnimation(Anim)
Animations[i] = Anim
end
local remote = script.blockact
local db = false
local db2 = false
local function stopallanims()
remote:FireServer('false',Player)
for i,v in pairs(Animations) do
if v.IsPlaying == true then
v:Stop()
end
end
end
UIS.InputBegan:Connect(function(input, Chat)
if Chat then return end
if input.KeyCode == Enum.KeyCode.F and IsBlocking.Value == false and IsAttacking.Value == false and db == false and IsStun.Value == false and Character.IsRagdoll.Value == false and Character.Humanoid.Health > 0 then
remote:FireServer('true',Player)
task.spawn(function()
db = true
task.wait(0.6)
db = false
end)
Character.IsRunning.Value = false
if Character:FindFirstChild("Avocet") then
Animations["spoonanim1"]:Play()
Animations["spoonanim2"]:Play()
elseif Character:FindFirstChild("Thorn") then
Animations["spearanim1"]:Play()
Animations["spearanim2"]:Play()
elseif Character:FindFirstChild("Felling Axe") then
Animations["axeanim1"]:Play()
Animations["axeanim2"]:Play()
elseif Character:FindFirstChild("Rifle") then
Animations["rifleanim1"]:Play()
Animations["rifleanim2"]:Play()
elseif Character:FindFirstChild("Dagger") then
Animations["knifeanim1"]:Play()
Animations["knifeanim2"]:Play()
elseif Character:FindFirstChild("Steel Sabre") then
Animations["swordanim1"]:Play()
Animations["swordanim2"]:Play()
elseif Character:FindFirstChild("Lancettes") then
Animations["timeanim1"]:Play()
Animations["timeanim2"]:Play()
else
Animations["anim1"]:Play()
Animations["anim2"]:Play()
end
end
end)
UIS.InputEnded:Connect(function(input, Chat)
if Chat then return end
if input.KeyCode == Enum.KeyCode.F then
local remote2 = script.RemoteEvent
remote2:FireServer('true',Player)
end
end)
IsBlocking:GetPropertyChangedSignal("Value"):Connect(function()
if IsBlocking.Value == false then
stopallanims()
else return
end
end)
IsAttacking:GetPropertyChangedSignal("Value"):Connect(function()
if IsAttacking.Value == true then
stopallanims()
else return
end
end)