I am planning to start working on my new game; it is going to be based off of sword fighting. I'm new to coding, and I need a bit of help on a basic code I can use that will disable fighting in a specific area (or areas) that I want it to be disabled in. This code is very much needed in the game, as the spawns are going to need it. Thank you, Emphadis.
Hi there what I will do in your case I will put this script in the area you don´t want fighting, what this script does it removes the players weapons when they touch that part heres the script, also if my answer is satisfactory don´t forget to give it a vote :D
-- This script removes all the weapons/items of anybody who touches it, except for those whose names -- are in the "keepers" list. keepers = {""} -- These are customizeable criteria regarding exactly what is removed, and where it is removed from: RemoveTools = true RemoveHopperBins = true RemoveFromBackpack = true RemoveFromCharacter = true RemoveForceField = false script.Parent.BrickColor = BrickColor.new() function getPlayer(humanoid) local players = game.Players:GetChildren() for i = 1, #players do if (players[i].Character.Humanoid == humanoid) then return players[i] end end return nil end function checkKeeper(player) for i = 1,#keepers do if (keepers[i] == player.Name) then return true end end return false end function RemoveWeapons(parent) local weapons = parent:GetChildren() for i = 1,#weapons do if (weapons[i].className == "Tool") and (RemoveTools == true) then weapons[i]:remove() script.Parent.BrickColor = BrickColor.new() elseif (weapons[i].className == "HopperBin") and (RemoveHopperBins == true) then weapons[i]:remove() script.Parent.BrickColor = BrickColor.new() end end end local debounce = false function onTouched(hit) local human = hit.Parent:findFirstChild("Humanoid") if (human == nil) then return end local player = getPlayer(human) if (player == nil) then return end if (checkKeeper(player) == true) or (debounce == true) then return end debounce = true if (RemoveFromBackpack == true) then local backpack = player.Backpack if (table.maxn(backpack:GetChildren()) > 0) then RemoveWeapons(backpack) end end if (RemoveFromCharacter == true) then RemoveWeapons(player.Character) end if (RemoveForceField == true) then local charparts = player.Character:GetChildren() for i = 1,#charparts do if (charparts[i].className == "ForceField") then charparts[i]:remove() script.Parent.BrickColor = BrickColor.new(22) end end end wait(0.5) script.Parent.BrickColor = BrickColor.new(21) debounce = false end script.Parent.Touched:connect(onTouched)