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

How would I give *1* forcefeild when a player touches a brick?

Asked by
Relatch 550 Moderation Voter
10 years ago

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.

1
Check if they have any in their character? Thetacah 712 — 10y
0
huh? Relatch 550 — 10y
0
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. Perci1 4988 — 10y
0
I still don't even know how to give them a forcefeild when they touch a brick. :/ Relatch 550 — 10y
0
Why not just not let them have weapons in the lobby until they spawn on the map? Tkdriverx 514 — 10y

2 answers

Log in to vote
1
Answered by
SirNoobly 165
10 years ago

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)
0
Thanks, I made a check to see if they already have one, and if they do it breaks the loop. Relatch 550 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago

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)

Answer this question