So i’m trying to make a weapon switch in my game, pressing Q or E switches your weapon, switching to mode 1 deletes weapon B and clones weapon A to your character, switching to mode 2 deletes weapon A and clones weapon B to your character.
--SERVER
local rp = game:GetService('ReplicatedStorage')
local ts = game:GetService('TweenService')
local CM = rp.Remotes.Character:WaitForChild('CharaMoves')
CM.OnServerEvent:Connect(function(p,Move,Mode)
if Move == "Switch" then
local c = p.Character
if Mode == "Gun" then
local cloned = rp.Weapons.EmptyGun:Clone()
cloned.Parent = c
cloned.GunHandle.Motor6D.Part0 = c["Right Arm"]
cloned.GunHandle.Motor6D.Part0 = cloned.GunHandle
c:FindFirstChild("CharaKnife"):Destroy()
end
end
end)
CM.OnServerEvent:Connect(function(p,Move,Mode)
if Move == "Switch" then
local c = p.Character
if Mode == "Knife" then
local cloned = rp.Weapons.CharaKnife:Clone()
cloned.Parent = c
cloned.Handle.Motor6D.Part0 = c["Right Arm"]
cloned.Handle.Motor6D.Part0 = cloned.Handle
c:FindFirstChild("EmptyGun"):Destroy()
end
end
end)
--CLIENT
local mcd = false
uis.InputBegan:Connect(function(k,istyping)
if istyping then
return
elseif k.KeyCode == Enum.KeyCode.Q or k.KeyCode == Enum.KeyCode.E then
if mcd == true then return
else
mcd = true
if mode == "Knife" then
mode = "Gun"
cm:FireServer("Switch",mode)
elseif mode == "Gun" then
mode = "Knife"
cm:FireServer("Switch",mode)
end
wait(0.9)
mcd = false
end
end
end)
what it does is that it DOES clone to your character but the CFrame is all messed up and then it gets deleted after a while, can someone explain why and help me solve this?