game.ReplicatedStorage.MainEvent.OnServerEvent:Connect(function(plr)
spawn(function()
plr.Character.Humanoid.WalkSpeed = 7
task.wait(.35)
plr.Character.Humanoid.WalkSpeed = 16
end)
local hitbox = Instance.new("Part")
hitbox.Parent = workspace
hitbox.CanCollide = false
hitbox.Anchored = true
hitbox.Size = Vector3.new(6,6,6)
hitbox.BrickColor = BrickColor.new("Really red")
hitbox.Transparency = .5
hitbox.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-3)
game.Debris:AddItem(hitbox,1)
local hitboxCooldown = false
hitbox.Touched:Connect(function(hit)
if hit.Parent.Name ~= plr.Name and plr.Parent:FindFirstChild("Humanoid") then
if hitboxCooldown == true then return end
hitboxCooldown = true
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(5)
local vfx = game.ReplicatedStorage.HitVFX.Attachment:Clone()
vfx.Parent = hit.Parent.HumanoidRootPart
local sound = script.slash:Clone()
sound.Parent = hit.Parent.HumanoidRootPart
sound:Play()
game.Debris:AddItem()
spawn(function()
for i,v in vfx:GetChildren() do
if v:IsA("ParticleEmitter") then
v:Emit(v:GetAttribute("EmitCount"))
end
end
end)
game.Debris:AddItem(vfx,1.5)
task.wait(1)
hitboxCooldown = false
end
end)
end)
#Hit not working
1 messages · Page 1 of 1 (latest)
It won't hit anything
if I mess with the code that stops me from hitting myself then I am able to hit myself and not others
Specifically if I do
game.ReplicatedStorage.MainEvent.OnServerEvent:Connect(function(plr)
spawn(function()
plr.Character.Humanoid.WalkSpeed = 7
task.wait(.35)
plr.Character.Humanoid.WalkSpeed = 16
end)
local hitbox = Instance.new("Part")
hitbox.Parent = workspace
hitbox.CanCollide = false
hitbox.Anchored = true
hitbox.Size = Vector3.new(6,6,6)
hitbox.BrickColor = BrickColor.new("Really red")
hitbox.Transparency = .5
hitbox.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-3)
game.Debris:AddItem(hitbox,1)
local hitboxCooldown = false
hitbox.Touched:Connect(function(hit)
if hit.Parent.Name ~= plr.Parent:FindFirstChild("Humanoid") then
if hitboxCooldown == true then return end
hitboxCooldown = true
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(5)
local vfx = game.ReplicatedStorage.HitVFX.Attachment:Clone()
vfx.Parent = hit.Parent.HumanoidRootPart
local sound = script.slash:Clone()
sound.Parent = hit.Parent.HumanoidRootPart
sound:Play()
game.Debris:AddItem()
spawn(function()
for i,v in vfx:GetChildren() do
if v:IsA("ParticleEmitter") then
v:Emit(v:GetAttribute("EmitCount"))
end
end
end)
game.Debris:AddItem(vfx,1.5)
task.wait(1)
hitboxCooldown = false
end
end)
end)
It will let the player hit themselves but not others
nevermind it will let them hit others but I need them to not be able to hit themselves
because i actually did the same thing, and it worked just fine for me
(except without the vfx parts because i didnt bother to put any assets in)
would you like me to share my hitbox code real fast?
sure
local hitbox = Instance.new("Part")
hitbox.Parent = workspace
hitbox.CanCollide = false
hitbox.Anchored = true
hitbox.Size = Vector3.new(5, 5, 5)
hitbox.BrickColor = BrickColor.new("Really red")
hitbox.Transparency = .5
hitbox.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -4)
game.Debris:AddItem(hitbox, 1)
local hitboxcooldown = false
hitbox.Touched:Connect(function(hit)
if hit.Parent.Name ~= plr.Name and hit.Parent:FindFirstChild("Humanoid") then
if hitboxcooldown == true then return end
hitboxcooldown = true
local hit_person = hit.Parent:FindFirstChild("Humanoid")
if hit_person:GetAttribute("IsBlocking") == false then
print(plr.Name .. " Hit " .. hit_person.Parent.Name .. " While IsBlocking was " .. tostring(hit_person:GetAttribute("IsBlocking")))
hit_person:TakeDamage(5)
hit_person.WalkSpeed = 7
task.wait(5)
hit_person.WalkSpeed = 16
else
print(plr.Name .. " Hit " .. hit_person.Parent.Name .. " While IsBlocking was " .. tostring(hit_person:GetAttribute("IsBlocking")))
end
end
end)
end)
obviously, with some added stuff
get rid of the "Isblocking" stuff
and it should work just fine
you’re doing if hit.parent.Name ~= plr.parent:findfirstchild(“Humanoid”)
isn’t plr the player itself? you need to add plr.character.. also im mobile so thats hard asf to read I might be wrong
thats exactly what i was thinking
i did the exact same tutorial as them
got it
best way to debug is adding a ton of print statements, so that you will isolate the error. Seems you jumped the gun posting this to a forum but it’s fair as you’re learning
yippe
one time i like um
i had this one script that fired a remote event that printed something
and it printed 3 times on one trigger and i was so confused
and then i posted it into a forum and people said there was nothing wrong with it
it turns out that the roblox ai literally made 2 seperate copies of the script
and it was all firing at the same time
💀💀 that ai is the death of all scripters
** You are now Level 4! **
I KNOWWWWWW
AND I DID SO MUCH WORK TYRING TO FIGURE OUT
WHAT WAS WRONG WITH IT
that’s not as bad as when i was making a system to log server console logs, and put the log function in a loop.. and with how studio works everything is a server console error so it bricked my studio every time i launched the game
We always screw ourselves somehow 🤣
I found a new issue 😦
hm?
my particles aren't disappearing and they appear on random hits and aren't consistant
particle effects are a pain in the ass
yeah
am i allowed to say that
um
maybe you can
add the debris to the part
that creates the vfx
im just taking a shot in the dark here i have no idea how to do vfx
if you disable them they don’t instantly disappear, if I recall even deleting them doesn’t. Only way to remove it instantly is moving the part the particles are connected to
^ that’s the ghetto fix i learned there’s probably a more efficient way to do it
😭🤣 We all do it
if it works it works
then you learn how to do it the “proper” way and it’s a slap in the face
LMAO real
i was struggling until i learned how to use attributes
Oh yeah they’re very useful, i used to abuse them until I learned module scripts
im still on the whole module script thing
** You are now Level 5! **
They have infinite uses I can’t go back anymore, any system I make is modular in some way