Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How To Deal Damage Once To A Player(FE)?

Asked by 6 years ago

How would I deal damage to a player when they are touched by a block, but only deal that damage once to that player while they are touching it and then if another player comes and touches the block then they only take the damage once, etc. I'm trying to make an attack that makes a giant "pool" all around them and then if a player touches it they take damage once and if a player walks into it, then they take the damage once. Any help? Also if anyone knows how to make a weapon equip from a script and not a tool then could you please go check out my previous post as well? Thanks.

1 answer

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago

try this:


--Server Script (Normal script) local brick = script.Parent local tbl= {} local dmg = 50 brick.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) local found = false for _,v in pairs(tbl) do if v == player.Name then found = true end end if not found then player.Character.Humanoid:TakeDamage(dmg) tbl[#tbl+1] = player.Name end end)
0
use table.insert(), other than that it looks pretty gud SmugNyan 24 — 6y
0
where exactly would i use table.insert? Wolf5429 15 — 6y
0
well, you can replace line 17 using table.insert(tbl,#tbl+1,player.Name) Rare_tendo 3000 — 6y
Ad

Answer this question