In my game, I have this lobby. But, players in the arena can kill other players in the lobby. I would like to know how to make a script inside of the brick that gives the player 1 forcefeild (not more than one because it lags the game) when they touch the brick.
✓ ANSWER ACCEPTED
How would I give *1* forcefeild when a player touches a brick?
2 answers
✓ Accepted answer
You need to check if the character has a forcefield inside it and if it doesn't, give it one.
script.Parent.Touched:connect(function(hit)
if not hit.Parent:FindFirstChild("ForceField") then -- if it doesn't find this then:
Instance.new("ForceField", hit.Parent) -- makes forcefield and puts into char
end
end)
1 comment
0
Thanks, I made a check to see if they already have one, and if they do it breaks the loop.
It says there is an error for me but when I tested it, It worked perfectly fine! :D
deb = false
function onTouched(part)
if deb == true then return end
deb = true
local ff = Instance.new("ForceField",part.Parent)
wait(3)
deb = false
end
script.Parent.Touched:connect(onTouched)
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
Check if they have any in their character?
huh?
Use an if statement and see if they have a force field in their character. If they do, don't do anything. If they don't, give them one.
I still don't even know how to give them a forcefeild when they touch a brick. :/
Why not just not let them have weapons in the lobby until they spawn on the map?