I have a script that when players step on a block they get a sword, but as soon as they step off of the block, the sword disappears. The script works perfectly fine until we use the :maprestore command from Kohls Commands [epix edit]. The maprestore is necessary for the game, but when we do it, the sf area block stops working completely. Script for block is below :
X1=script.Parent.Position.X-script.Parent.Size.X*.5 X2=script.Parent.Position.X+script.Parent.Size.X*.5 Z1=script.Parent.Position.Z-script.Parent.Size.Z*.5 Z2=script.Parent.Position.Z+script.Parent.Size.Z*.5 game.Players.PlayerAdded:connect(function(Plr) repeat wait() until Plr.Character:FindFirstChild("Torso") local PlrIn=false while wait() do if X1<Plr.Character.Torso.Position.X and Plr.Character.Torso.Position.X<X2 and Z1<Plr.Character.Torso.Position.Z and Plr.Character.Torso.Position.Z<Z2 then if PlrIn==false then print("Player is inside") PlrIn=true local WeaponClone=game.Lighting.Sword:clone() WeaponClone.Parent=Plr.Character end else if PlrIn==true then if Plr.Character:FindFirstChild("Sword") then Plr.Character:FindFirstChild("Sword"):remove() elseif Plr.Backpack:FindFirstChild("Sword") then Plr.Backpack:FindFirstChild("Sword"):remove() end print("Player is outside") PlrIn=false end end end end)
-FredMango
Woah there. It seems like you're overthinking this a bit too much. That 30 line script could be turned into 18 lines, using 2 events. The Touched event, and the TouchEnded event. Since all you're trying to do is have them remove a sword once they step off, these two events will come in handy, rather than checking their position. You're fixed up script: (Put this directly as a child of the part)
script.Parent.Touched:connect(function(hit) if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then local p = game.Players:GetPlayerFromCharacter(hit.Parent) game.Lighting.Sword:clone().Parent = p.Character end end) script.Parent.TouchEnded:connect(function(unhit) if unhit.Parent and game.Players:GetPlayerFromCharacter(unhit.Parent) then local p = game.Players:GetPlayerFromCharacter(unhit.Parent) if p.Backpack:findFirstChild("Sword") then p.Backpack.Sword:Destroy() end if p.Character:findFirstChild("Sword") then p.Character.Sword:Destroy() end end end)