I have a forcefield script that works great. The thing is, I want it to disable after the user drops to the arena floor. He's my forcefield script:
Game:GetService"Players".PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Character) Instance.new("ForceField",Character) end) end)
With my lack of knowledge, I have no clue how to disable forcefield once the user touches the arena floor. I tried but it looked nothing like the above, and it broke the entire script. Any suggestions?
Using a touched event, we can remove the ForceField from the character (but not before checking to see if it exists):
PART.Touched:connect(function(hit) if (hit.Parent:FindFirstChild("ForceField")) then hit.Parent.ForceField:Destroy() end end)
Where PART is the location of the part object in the workspace (e.g. game.Workspace.FFRemover).
You lack a wait for child in your method. And what you want to do is a touched event for that object, being the base..
Game:GetService"Players".PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Character) Instance.new("ForceField",game.workspace:WaitForChild(Character.Name))//we need to get the name end) end) --add a Touched event for your floor --the script should be inside floor script.Parent.Touched:connect(function(player) //touched event allows you to give you the model of the player and using the paramater as other part if(player.Humanoid ~=nil) then player.ForceField:Destroy()-- calls the destroy function, which removes the ForceField that was parent end end)
a side note, : means after this that it is a function Every Object in roblox.lua has events, Each event requires :connect and passes in a paramater or a function that is made anon within the paramaters or outside the paramaters.