Guys i was making a sword type of script and i also have a local script that detects the mousebutton 1 and mousebutton 2 held but the script that i have isnt working. I get some prints like “equipped” at the start of the game and then when i equip the tool, according to the script when i touch the baseplate it doesnt print which is odd.
wait()
local rem = game.ReplicatedStorage.playa
rem.OnServerEvent:Connect(function(player)
local tool = script.Parent
local Equipanimation = script.EquipAnimation
local UnequipAnimation = script.UnequipAnimation
local humanoid
local remote1 = game.ReplicatedStorage.Light
local remote2 = game.ReplicatedStorage.Block
local character = player.Character
local Equip = script:WaitForChild("Sound")
local unEquip = script:WaitForChild("Sound2")
local block = Instance.new("BoolValue",player.Character)
block.Name = "Block"
local delay = 0.3
local block1 = Instance.new("Animation")
block1.AnimationId = "rbxassetid://6512534347"
local blockanim1 = script.Parent.Parent.Humanoid:LoadAnimation(block1)
local blockau1 = Instance.new("Sound")
blockau1.SoundId = "rbxassetid://6512152579"
tool.Equipped:Connect(function()
script.Parent.Stamina.Parent = player.PlayerGui
humanoid = tool.Parent:FindFirstChild("Humanoid")
local loader = humanoid:LoadAnimation(Equipanimation)
loader:Play()
Equip:Play()
print("Equippped")
--//Attacking Animations\\--
local UserInputService = game:GetService("UserInputService")
local Tool = script.Parent
local CanAttack = true
local Anim_Name = "Attack"
local Attack_Num = 1
local blade = game.Workspace.Baseplate --(update this to where the sword is)
blade.Touched:Connect(function(hit)
print("hit")
print(CanAttack)
if CanAttack == false and hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Block == false then
hit.Parent.Humanoid:TakeDamage(15)
end
end
end)
local UIS = game:GetService("UserInputService")
local held = false
remote2.OnServerEvent:Connect(function(held)
if held == true then
print("blocking")
blockanim1:Play()
blockau1:Play()
block.Value = true
end
if held == false then
blockanim1:Stop()
blockau1:Stop()
block.Value = true
end
end)
remote1.OnServerEvent:Connect(function()
local swing1 = Instance.new("Animation")
swing1.AnimationId = "rbxassetid://6512534347"
local Animation1 = script.Parent.Parent.Humanoid:LoadAnimation(swing1)
local swing2 = Instance.new("Animation")
swing2.AnimationId = "rbxassetid://6512534347"
local Animation2 = script.Parent.Parent.Humanoid:LoadAnimation(swing2)
if CanAttack == true then
CanAttack = false
Animation1:Play()
local Audio1 = Instance.new("Sound")
Audio1.SoundId = "rbxassetid://6512152579"
local Audio2 = Instance.new("Sound")
Audio2.SoundId = "rbxassetid://536642316"
Audio1:Play()
-- CanAttack = false (moved this to above the playing of the anims, to make sure it is already false when the onTouched is triggered
wait(1)
CanAttack = true
if Attack_Num == 1 then
character:PivotTo(character:GetPivot() * CFrame.new(0, 0, -7))
Attack_Num = Attack_Num + 1
print("Attack1")
else if Attack_Num == 2 then
character:PivotTo(character:GetPivot() * CFrame.new(0, 0, -7))
Attack_Num = 1
Audio2:Play()
Animation2:Play()
print("Attack2")
end
end
end
end)
end)
tool.Unequipped:Connect(function()
local loader = humanoid:LoadAnimation(UnequipAnimation)
loader:Play()
unEquip:Play()
script.Parent.Stamina.Parent = script.Parent
print("Unequipped")
end)
end)
any help will be appreciated.
