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

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

Asked by
Relatch 550 Moderation Voter
9 years ago

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

Log in to vote
2
Answered by
SanityMan 239 Moderation Voter
9 years ago

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!

0
Thanks very much. Relatch 550 — 9y
0
No problem! SanityMan 239 — 9y
0
Wait, hold on, I'm using spawn locations and it contains a force field that is messing with the script. Relatch 550 — 9y
0
Nevermind, I fixed it. Thanks again! Relatch 550 — 9y
View all comments (2 more)
0
Try going into the Spawn Location's properties and setting the \ SanityMan 239 — 9y
0
oh, ok. SanityMan 239 — 9y
Ad
Log in to vote
-1
Answered by 9 years ago

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.

Answer this question