its suppose to be a script that gives you a permanent forcefield around your player so you can never die but it doesn't really work. :/
function newPlayer(player) local ff = Instance.new("ForceField") ff.Parent = player.Character.Torso end game.Players.PlayerAdded:connect(newPlayer)
Force Fields don't go inside the player's torso. It only goes inside the character:
function newPlayer(player) local ff = Instance.new("ForceField") ff.Parent = player.Character end game.Players.PlayerAdded:connect(newPlayer)
Also, did you know that Instance.new()
has 2 arguments? The object and the parent! So line 3 isn't needed.
function newPlayer(player) local ff = Instance.new("ForceField", player.Character) --Notice the "player.Character" end game.Players.PlayerAdded:connect(newPlayer)
EDIT
Like how the Jash50 said. Maybe the character hasn't been added yet because this script runs when the player joins the game. But when this happens the game isn't fully loaded for that player. Use this script to wait until the character is loaded.
game.Players.PlayerAdded:connect(function(plyr) plyr.CharacterAdded:connect(function(char) --Wait for the character to be added. local ff = Instance.new("ForceField", char) end) end)
Also, if the player dies the character is added again so the function is triggered again. You don't need to have any Died event
here.
Maybe the character doesn't loaded yet.. so you can make it like this:
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) local ff = Instance.new("ForceField") ff.Parent = character.Torso end) end)
Edit:
This should work:
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) local ff = Instance.new("ForceField", character) end) end)
Locked by EzraNehemiah_TF2 and BlueTaslem
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?