I have already made a very VERY simple punching system but now if I want to add weapons like a baseball bat I need to do some more stuff? I’m really confused. I’m also very new to developing games and scripting so I’m sorry if I’m very bad. Thanks for reading
also here is the code
local character = script.Parent
local rightArm = script.Parent:WaitForChild("Right Arm")
local leftArm = script.Parent:WaitForChild("Left Arm")
local rightLeg = script.Parent:WaitForChild("Right Leg")
local leftLeg = script.Parent:WaitForChild("Left Leg")
local player = game.Players.LocalPlayer
local camerra = workspace.CurrentCamera
local humanoid = character.Humanoid
local alreadyAttack = false
local damaging = false
local camPart = workspace.Intro:FindFirstChild("Camera")
local animationR = game.ReplicatedStorage.Animations.PunchR
local animationL = game.ReplicatedStorage.Animations.PunchL
local uis = game:GetService("UserInputService")
local mouse = player:GetMouse()
----function
mouse.Button1Down:Connect(function()
if not alreadyAttack then
alreadyAttack = true
local animL = humanoid:LoadAnimation(animationL)
animL:Play()
wait(0.5)
alreadyAttack = false
end
end)
mouse.Button2Down:Connect(function()
if not alreadyAttack then
alreadyAttack = true
local animR = humanoid:LoadAnimation(animationR)
animR:Play()
wait(0.5)
alreadyAttack = false
end
end)
rightArm.Touched:Connect(function(hit)
if alreadyAttack == false and damaging == false then
print("Not attacking")
print(hit)
elseif hit.Parent:FindFirstChild("Humanoid") ~= nil then
if damaging == true then
print("damaging")
else
damaging = true
hit.Parent.Humanoid:TakeDamage(5)
wait(0.5)
damaging = false
end
elseif hit.Parent.Name == player.Name then
print("This is the player")
end
end)
leftArm.Touched:Connect(function(hit)
if alreadyAttack == false and damaging == false then
print("Not attacking")
print(hit)
elseif hit.Parent:FindFirstChild("Humanoid") ~= nil then
if damaging == true then
print("damaging")
else
damaging = true
hit.Parent.Humanoid:TakeDamage(5)
wait(0.5)
damaging = false
end
elseif hit.Parent.Name == player.Name then
print("This is the player")
end
end)
Here is some more information.
I’m using R6
This script is local
and i’m very bad at scripting