generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How to only damage player once after sword hit?

Previous Thread :: Next Thread 
SerGregor is not online. SerGregor
Joined: 17 Jul 2010
Total Posts: 7957
22 May 2016 04:09 PM
local Damager = sword.Touched:connect(function(Hit)
if Hit and Hit.Parent and Hit.Parent:FindFirstChild("Humanoid") then

end
end)

ive done MANY attempts on doing this correctly, and that's the base of the event so i can just show you what i mean

so i got a sword, and on that specific slash, it should give 40 damage ONCE to each player it hits, then next slash it does the same, etc, etc

like, i seem to have problems scripting the correct debounce for this..
Report Abuse
SerGregor is not online. SerGregor
Joined: 17 Jul 2010
Total Posts: 7957
22 May 2016 04:19 PM
bump
Report Abuse
Lem0nzzx is not online. Lem0nzzx
Joined: 08 Feb 2016
Total Posts: 1604
22 May 2016 04:20 PM
local deb = false
local Damager = sword.Touched:connect(function(Hit)
if deb == false then deb = true
if Hit and Hit.Parent and Hit.Parent:FindFirstChild("Humanoid") then

end
wait(1)
deb = false
end
end)


Report Abuse
SerGregor is not online. SerGregor
Joined: 17 Jul 2010
Total Posts: 7957
22 May 2016 04:21 PM
nope can't do that one, because what if the sword hits two person at once? it'll only damage one
Report Abuse
Lem0nzzx is not online. Lem0nzzx
Joined: 08 Feb 2016
Total Posts: 1604
22 May 2016 04:23 PM
local deb = false
local Damager = sword.Touched:connect(function(Hit)
if deb == false then deb = true
if Hit and Hit.Parent and Hit.Parent:FindFirstChild("Humanoid") then

end
wait(.1)
deb = false
end
end)


Report Abuse
SerGregor is not online. SerGregor
Joined: 17 Jul 2010
Total Posts: 7957
22 May 2016 04:24 PM
that's not reliable at all, that's a hope and gamble.
Report Abuse
Lem0nzzx is not online. Lem0nzzx
Joined: 08 Feb 2016
Total Posts: 1604
22 May 2016 04:30 PM
local plr = nil
local deb = false
script.Parent.Touched:connect(function(hit)
if deb == false then deb = true
if hit.Parent:findFirstChild("Humanoid") and plr ~= hit.Parent.Name then
--damage
plr = hit.Parent.Name
wait(1)
plr = nil
end
wait()
end
end)




Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
22 May 2016 04:37 PM
I'd do it like this.

EDIT: ROBLOX is blocking the code for some stupid reason. Use this Pastebin:
pastebin/EWwXn9S2
Report Abuse
SerGregor is not online. SerGregor
Joined: 17 Jul 2010
Total Posts: 7957
23 May 2016 11:58 AM
bump it didnt work
Report Abuse
Slydexia is not online. Slydexia
Joined: 10 Aug 2010
Total Posts: 98517
23 May 2016 12:02 PM
hitppl = {}

alreadyHit = false

function onhit(hit)
alreadyHit = false
for a = 1,#hitppl do
if hitppl[a] == hit.Parent then
alreadyhit = true
end
if alreadyHit == false then
table.insert(hit.Parent)
--DO YOUR HITTING HERE
end
end

and in the swinging part of the code, just have the table reset after each swing
like this:

hitppl = {}

then you can hit them with another swing.
Report Abuse
SerGregor is not online. SerGregor
Joined: 17 Jul 2010
Total Posts: 7957
23 May 2016 12:11 PM
full of errors and i dont think it'll work because i did something like that
Report Abuse
Slydexia is not online. Slydexia
Joined: 10 Aug 2010
Total Posts: 98517
23 May 2016 12:19 PM
i forgot a second 'end' after the first check. try that.
Report Abuse
ownedyou1 is not online. ownedyou1
Joined: 03 Jul 2008
Total Posts: 528
23 May 2016 12:20 PM
add this to ur on hit script for the sword then;
local damage=420/100
local time=0.5
local deb=false

function on(hit)
local hum=hit.Parent:findFirstChild("Humanoid")
if deb==false and hum~=nil then

deb=true
hum.Health=hum.Health-damage
wait(time)
deb=false
else


end


end

script.Parent.Sword.Touched:connect(on)
Report Abuse
Inigo18 is not online. Inigo18
Joined: 02 Feb 2014
Total Posts: 1041
23 May 2016 12:22 PM
ffs, you cannot hit two players at once. ROBLOX is not that slow you know. "dis doesnt work omg" proves you didn't even try it.
Report Abuse
SerGregor is not online. SerGregor
Joined: 17 Jul 2010
Total Posts: 7957
23 May 2016 12:24 PM
@owned nope

@inigo

"gonna be of no help whatsoever and just complain on this guy for no good reason because im in a bad mood"
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image