Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How could I make a script that lets a player keep a forcefield until they equip a sword?

I'm trying to prevent players from being afk killed, or ff killed. I know this can be a problem for other games, and I want it to be fixed in my game if it can be done. I'm not sure how I would start this, but i think it will be something like this.

sword = ClassicSword
player = game.Players.Localplayer
ff = Instance.new("ForceField")
ff.Parent = player

And, that's all my knowledge on this. Help?

2 answers

✓ Accepted answer

Utilize the Equipped event of tools. Make a local script in your starter pack that says something like this:

tool = game.Players.LocalPlayer.Backpack["YOUR_TOOL_NAME_HERE"]
ff = Instance.new("ForceField", game.Players.LocalPlayer.Character)
tool.Equipped:connect(function()
ff:remove()
end)

I hope this works for you!

6 comments

0

Thanks very much.

0

No problem!

0

Wait, hold on, I'm using spawn locations and it contains a force field that is messing with the script.

0

Nevermind, I fixed it. Thanks again!

0

Try going into the Spawn Location's properties and setting the \

0

oh, ok.

If a person doesn't have a tool equipped, then the parent of that tool is the player's backpack. (Players) If you have a tool equipped, the parent is the character. (Workspace)

First of all, we don't know what the sword's name is. A script like this would probably require the name of the sword. Please edit your answer and make a variable for the sword.

This discussion is preserved as it was. New answers, comments, and votes are closed.