Hi, I've been trying to make a sword equip with a button press and then get removed when I press that same button. It worked fine without FE, but when I transferred the script to FE, I haven't been able to remove it. I also tried separating the scripts into separate ones, but that didn't help either. I'm a newbie to Filtering Enabled, and it broke one of my previous games that I had been scripting. I'm using cloning and welding to put the sword in the hand. Also, I've been working on dual wielding a sword and a shield. (although that's not really relevant right now.) I'll put my code just in case if it helps anything. OLD Local side:
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(keyF)
if keyF == 'f' then
game.ReplicatedStorage.Equip:FireServer()
end
end)
New Local side; thanks NiniBlackJackQc!:
local Player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.F then
game.ReplicatedStorage.Equip:FireServer()
end
end)
Server side:
game.ReplicatedStorage.Equip.OnServerEvent:Connect(function(player)
local Character = player.Character
local hand = Character.RightHand
local Equipy = player.Character.Values.Equip.Value
local Unsheath = script.Weapons.MasterSword.attack.Animations.Unsheath
local sheathUn = Character.Humanoid:LoadAnimation(Unsheath)
if Equipy == true then
wait()
sheathUn:Play()
local sword = script.Weapons.MasterSword
local cloneSword = sword:Clone()
local scriptt = cloneSword.attack
cloneSword.Parent = Character
cloneSword.Union.Anchored = false
cloneSword.Handle.Anchored = false
local weld = Instance.new("Weld")
weld.Parent = cloneSword.Handle
weld.Part0 = Character.RightHand
weld.Part1 = cloneSword.Handle
scriptt.Disabled = false
Equipy = false
end
end)
Also, please report any errors in my code. Thanks :D

2 comments
Mouse is deprecated use UserInputService https://developer.roblox.com/api-reference/class/UserInputService
Thanks for pointing that out :D