#How do i make the sword deal damage to other players?

1 messages · Page 1 of 1 (latest)

sturdy solstice
#

A simple way to achieve only doing damage to each hit player a single time is to store hit players in a table.

For example:

local tool = script.parent
local debounce = nil
local hitPlayers = {}

local function Attack()
  if debounce == nil then
      hitPlayers = {}
    --(The rest of your code; I'm too lazy to write it lol)
  end
end

tool.Activated:Connect(Attack)

tool.Handle.Blade.Touched:Connect(function(hit)
  local player = game.Players:GetPlayerFromCharacter(hit.Parent)

  if player and debounce == true and not table.find(hitPlayers, player.UserId) then
  table.insert(hitPlayers, player.UserId)

  --(Rest of your code)
 end
end)
full sleet
#

that means like this?

sturdy solstice
#

I'm assuming you're going to get rid of the extra code at the end and not have two .Touched and .Activated's, so yeah, basically like that

#

I probably forgot some things in the snippet I provided, so make sure not to just copy and paste it, as well, since it probably won't work

full sleet
#

i can see that line 8 is in red line

sturdy solstice
#

just add )

full sleet
#

to there?

sturdy solstice
#

after the "end"

#

it'll get rid of the error

full sleet
#

still red

#

I TRRYED EVERY END NONE WORKED

#

srry caps

sturdy solstice
#

It isn't defining an animTrack variable lol

full sleet
#

what does that mean?

#

the animation worked before

sturdy solstice
#

You removed the: local animTrack = etc.

full sleet
#

oh

sturdy solstice
#

as well as the ones for the humanoid and animation itself lol

full sleet
#

now the end is red

cold rainBOT
#

studio** You are now Level 2! **studio

sturdy solstice
#

Make sure to put hit back in the tool.Handle.Blade.Touched:Connect(function()

cold rainBOT
#

studio** You are now Level 2! **studio

sturdy solstice
#

also

#

uh

#

why is there a .Touched in the .Touched 😭

full sleet
#

where?

sturdy solstice
full sleet
#

remove this then?

sturdy solstice
#

Yes, and the extra tool.Activated in there

full sleet
#

like this?

sturdy solstice
#

You should also remove the extra local player and the if player and debounce in there, since you're already checking those right above it. Make sure not to remove the line that damages the player, though

#

Also put "hit" in the parenthesis of the "function()" at the very top

full sleet
#

literally guessing if its right

sturdy solstice
#

Closer

full sleet
#

closer?

sturdy solstice
#

Indeed

full sleet
#

wdym by that?

sturdy solstice
#

If you put "hit" in the parenthesis of the function() at the top, it should technically work (I think). But, the if player and debounce== true is redundant since you're already checking them above it

full sleet
#

what are parenthesis? xD

sturdy solstice
#

()

full sleet
#

removre {} and add ()?

sturdy solstice
#

no

#

I mean

full sleet
#

wich line?

sturdy solstice
#

The line that says tool.Handle.Blade.Touched:Connect(function() on the top of your most recent picture

full sleet
#

ah

sturdy solstice
#

add hit in the parenthesis so the exact line should be:

tool.Handle.Blade.Touched:Connect(function(hit)

full sleet
#

like that?

#

hit isnt red anymore

#

but the end is

sturdy solstice
#

indeed it isn't

#

you put hit in the correct place

full sleet
#

yo i put ) on the end now theres no more red

#

still dont work bruh

sturdy solstice
#

interesting

#

Uh

#

Just for clarification

#

Are you hitting a rig?

full sleet
sturdy solstice
#

Indeed it seems you are

full sleet
#

is that a problem?

sturdy solstice
#

Alright, so with your original code, it was written to only work on other players

full sleet
#

technicly i only need it for other players but i wanna test it and i cant find someone else to test it with

sturdy solstice
#

You can create a local test that simulates having multiple players

#

Go to the test tab and find this

#

then switch it to 2 Players and press start

full sleet
#

i have the new version xD

full sleet
sturdy solstice
#

I forgot they added that horrendous new studio to the beta features 😔

#

yeah that's it

full sleet
#

what do i click?

sturdy solstice
#

hover over start test session

full sleet
#

server and client?

sturdy solstice
#

uh nevermind

#

Uh

#

I opened up the studio with the new ui, let me find it rq

full sleet
#

ok

errant drift
#

just use old studio

cold rainBOT
#

studio** You are now Level 1! **studio

#

studio** You are now Level 3! **studio

full sleet
#

how

errant drift
sturdy solstice
errant drift
#

beta features is in file at the top

#

scroll down and you should see it

sturdy solstice
#

though I did just figure it out in the new one

#

it's weird

full sleet
#

ah got it

#

still not working animation also doesnt work

#

do u mind if u can add u in the game and u see urself?

sturdy solstice
#

Yeah sure why not at this point

full sleet
#

ok whats ur user?

#

oh need u be friended to make u edit

#

send request

sturdy solstice
#

Alright, I accepted it

cold rainBOT
#

studio** You are now Level 3! **studio

full sleet
#

made you edit

sturdy solstice
#

try now

full sleet
#

team test?

sturdy solstice
#

sure

errant drift
sturdy solstice
full sleet
#

yo i did

errant drift
sturdy solstice
errant drift
#

also hou can use :TakeDamage() @full sleet

#

in the future

full sleet
#

idk man im not a scripter

errant drift
#

did you base this off a tutorial

full sleet
#

maybe

errant drift
#

or just tried writing it yourself

full sleet
#

tutorial and kruz

sturdy solstice
#

join the team test rq

#

should be working now

errant drift
full sleet
#

aint no way it works finally

errant drift
#

mustve not been a very good tutorial

full sleet
sturdy solstice
#

I put the line to reset the table in the wrong spot 😔

full sleet
#

this is the one i used

sturdy solstice
#

should work properly now I think

#

team test

full sleet
#

do i close this post or?

sturdy solstice
#

Idk

errant drift
#

also @sturdy solstice

sturdy solstice
#

?

errant drift
#

youve used render stepped before right

sturdy solstice
#

Indeed

errant drift
#

can you check my post again and see if anything looks off

full sleet
#

yo @sturdy solstice

sturdy solstice
#

?

cold rainBOT
#

studio** You are now Level 4! **studio

full sleet
#

you may be annoyed from me but can u help me make a intermission system? xD i could pay you 23 robux its all i got

#

?

sturdy solstice
full sleet
#

ok

cold rainBOT
#

studio** You are now Level 4! **studio