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

How do I make force fields last infinite?

Asked by 3 years ago

I'm trying to make a game with anti team kill but the only way to do that is to use force fields, the force fields do not last forever even though I made the forcefield time on the spawn infinite. Any help would be amazing.

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

If you want to give a player an indefinitely lasting force field, you have to insert a new force field into their character.

The code below gives the player an infinite force field every time their character spawns.

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        local field = Instance.new("ForceField")
        field.Parent = char
    end)
end)

Although, force fields aren't the only way to avoid team-killing. You can have the weapons check for the holder's team, and the team of player who gets hit, and determine whether or not the player should take damage.


Good luck with your further development! :D

~Sethex, aka. TheWaterFoox

0
Damn thanks so much, I will try this now! :) ElongatedMongoose 138 — 3y
0
This helped so much, works perfectly. This is very important to my game I cant thank you enough! ElongatedMongoose 138 — 3y
Ad

Answer this question