Hello guys!
I am currently making a lightsaber game.
evry thing is going well but now i need to add blocking and i need help
i want to make it so when this value = enabled
the attackdmg of the player that attacks will be a dif value
i need to detect the players character the hitbox hit…
the attack code
Code:
local remoteEvent = script.Parent.Parent.AttackFolder.Attack1
local tool = script.Parent.Parent
local plr = tool.Parent.Parent
local char = plr.Character
local m1 = script.Parent.Parent.Handle.Hit
local Damage = script.Parent.Parent.dmgfolder.dmg.Value
local RaycastHitbox = require(game.ServerScriptService.RaycastHitboxV4)
local Hitbox = RaycastHitbox.new(script.Parent.Parent["Lightsaber top"].Part)
hitted = false
blockhitted = false
remoteEvent.OnServerEvent:Connect(function()
Hitbox:HitStart()
local Attack = script.Parent.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Parent.Anims.Attack1)
print("Server Attack1!")
Hitbox.OnHit:Connect(function(hit, humanoid)
if hitted then return end
hitted = true
if humanoid.Parent ~= char then
humanoid:TakeDamage(Damage)
m1:Play()
print(hit.Name)
humanoid:LoadAnimation(script.Parent.Parent.Anims.Hit) -- does not work i cant locate the humanoid i hit
end
hitted = false
end)
Attack:Play()
wait(0.3)
Hitbox:HitStop()
end)
wait(2)
m1:Stop()
the attackdmg folder:
i want to use the blockdmg value for this
i have tried many things but all of them don’t seem to work…
local m2 = script.Parent.Parent.Handle.Hitter1
local remoteEvent = script.Parent.Parent.AttackFolder.Attack2
local tool = script.Parent.Parent
local plr = tool.Parent.Parent
local char = plr.Character
local Damage = script.Parent.Parent.dmgfolder.dmg2.Value
local Damage1 = script.Parent.Parent.dmgfolder.Blockdmg.Value
local RaycastHitbox = require(game.ServerScriptService.RaycastHitboxV4)
local Hitbox = RaycastHitbox.new(script.Parent.Parent["Lightsaber top"].Part)
local ls = script.Parent.Parent
hitted = false
remoteEvent.OnServerEvent:Connect(function()
Hitbox:HitStart()
local Attack = script.Parent.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Parent.Anims.Attack2)
print("Server Attack2!")
Hitbox.OnHit:Connect(function(hit, humanoid)
if hitted then return end
hitted = true
if humanoid.Parent ~= char then
if humanoid.Parent:FindFirstChild("ls").Blocking.Value == true then
humanoid:TakeDamage(Damage1)
end
if humanoid.Parent:FindFirstChild("ls").Blocking.Value == false then
humanoid:TakeDamage(Damage)
end
local hit = humanoid:LoadAnimation(game.ReplicatedStorage.Hitanim2)
hit:Play()
m2:Play()
print(hit.Name)
end
hitted = false
end)
Attack:Play()
wait(0.4)
Hitbox:HitStop()
end)
wait(2)
m2:Stop()
local m1 = script.Parent.Parent.Handle.Hit
local remoteEvent = script.Parent.Parent.AttackFolder.Attack2
local tool = script.Parent.Parent
local plr = tool.Parent.Parent
local char = plr.Character
local Damage = script.Parent.Parent.dmgfolder.dmg.Value
local Damage1 = script.Parent.Parent.dmgfolder.Blockdmg.Value
local RaycastHitbox = require(game.ServerScriptService.RaycastHitboxV4)
local Hitbox = RaycastHitbox.new(script.Parent.Parent["Lightsaber top"].Part)
local ls = script.Parent.Parent
hitted = false
remoteEvent.OnServerEvent:Connect(function()
Hitbox:HitStart()
local Attack = script.Parent.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Parent.Anims.Attack1)
print("Server Attack1!")
Hitbox.OnHit:Connect(function(hit, humanoid)
if hitted then return end
hitted = true
if humanoid.Parent ~= char and humanoid.Blocking.Value == 1 then
print("blockhit")
humanoid:TakeDamage(Damage1)
else if humanoid.Parent ~= char and humanoid.Blocking.Value == 0 then
local hit1 = humanoid:LoadAnimation(game.ReplicatedStorage.Hitanim1)
print("Hit")
humanoid:TakeDamage(Damage)
hit1:Play()
end
m1:Play()
print(hit.Name)
end
hitted = false
end)
Attack:Play()
wait(0.4)
Hitbox:HitStop()
end)
wait(2)
m1:Stop()
this will only work if the player has an “IntValue” in the charactershumanoid
now the question is…
how do i make it so when a player is ingame he has a intvalue in hes humanoid?