-
What do you want to achieve? Keep it simple and clear!
Im trying to make a custom system in which my mecha can dual wield multiple weapons without having to be hardcoded. I’ve mostly succeeded so far but im struggling with some replication issues. -
What is the issue? Include screenshots / videos if possible!
My mecha is equipped with 2 guns, 1 is assigned to the right hand and 1 to the left.
I press “R” to equip the left one via tool parenting and equip the other normally. The system works by first equipping to the right hand and taking the grip weld and putting it onto the left hand. So far this works perfectly on client. But for some reason doesnt replicate to the server unless Im already dual wielding. Further inspection shows that on the servers side the grip is not created in the right hand until I equip the righthanded weapon and Im not sure why this happens.
Client Side - Left handed tool is equipped without fault
https://gyazo.com/0d3c043931bc31f4adc57a46fc4b4a67
Server Side - Tool spawns on ground as there is apparently no grip for it to “steal”
https://gyazo.com/70cddfd75eff1c5b2ccd9b9658f325f1
Client/Server - After equipping the right handed tool first the tools then work properly on both client and server
https://gyazo.com/7da3cc07279b684e4a58b2ae37797400
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Ive tried creating a new server side weld but this makes things more complicated and broke a lot more things. Im not sure what to do
Client Script that handles equipping the tool
local RS = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer
local c = workspace.CurrentCamera
wait(1)
local character = Player.Character
print(character)
local GunEquip = ReplicatedStorage.TSFWeapons.ServerEvents.GunEquip
local HoldAnim = script:WaitForChild("HoldGunRight")
local HoldAnimL = script:WaitForChild("HoldGunLeft")
local humanoid = script.Parent.Parent.Parent.Parent.Character:WaitForChild("Humanoid")
local HoldTrack = humanoid.Animator:LoadAnimation(HoldAnim)
local HoldTrackL = humanoid.Animator:LoadAnimation(HoldAnimL)
local Tool = script.Parent.Parent
local gunEquipped = false
local hardpoint = Tool.Handle.AssignedHardpoint
Tool.Equipped:Connect(function()
if hardpoint.Value == "LH" then
if Tool.Parent.RightHand:WaitForChild("RightGrip") then
Tool.Parent.RightHand.RightGrip.Parent = Tool.Parent.LeftHand
Tool.Parent.LeftHand.RightGrip.Part0 = Tool.Parent.LeftHand
GunEquip:FireServer(Tool)
HoldTrackL:Play()
gunEquipped = true
end
else
HoldTrack:Play()
gunEquipped = true
end
end)
Tool.Unequipped:Connect(function()
HoldTrack:Stop()
gunEquipped = false
end)
Server script handling equipping
local ReplicatedStorage = game:WaitForChild("ReplicatedStorage")
local GunEquipped = ReplicatedStorage.TSFWeapons.ServerEvents.GunEquip
GunEquipped.OnServerEvent:Connect(function(player, Tool)
if Tool.Parent:IsA("Backpack") then
return
else
if Tool.Parent.RightHand:WaitForChild("RightGrip") then
Tool.Parent.RightHand.RightGrip.Parent = Tool.Parent.LeftHand
Tool.Parent.LeftHand.RightGrip.Part0 = Tool.Parent.LeftHand
end
end
end)
Its probably worth noting that when equipping the left handed tool on its own
a warning is presented…
Infinite yield possible on 'Workspace.Player1.RightHand:WaitForChild("RightGrip")'