Tool grip not being replicated through :FireAllClients()

I’m scripting a tool that changes its grip when the Activated and Deactivated events are called. Since the tool grip is important to the animation that plays with it, I want other players to be able to see this change. This is also a change that will occur frequently, so I’m using :FireAllClients() to avoid putting unnecessary strain on the server.

This is currently what I have:

--localscript; this script is inside of the tool
local sword = script.Parent --reference to the tool

local replicateGrip = game:GetService("ReplicatedStorage"):WaitForChild("ReplicateGrip") --remoteevent
--default grip
	local defaultPos = Vector3.new(0, -0.5, -0.1)
	local defaultUp = Vector3.new(0, 1, 0)
--charge grip
	local chargePos = Vector3.new(0, -0.4, 0.1)
	local chargeUp = Vector3.new(0, -1, 0)

function changeGrip(_tool, toolPos)
	--second argument, a string, determines what to set the tool grip to
	if toolPos == "default" then
		_tool.GripPos = defaultPos
		_tool.GripUp = defaultUp
	elseif toolPos == "charge" then
		_tool.GripPos = chargePos
		_tool.GripUp = chargeUp
	end
	return toolPos
end

replicateGrip.OnClientEvent:Connect(function(_tool, toolPos)
	changeGrip(_tool, toolPos)
end)

sword.Activated:Connect(function()
	replicateGrip:FireServer(sword, "charge") 
end)

sword.Deactivated:Connect(function()
	replicateGrip:FireServer(sword, "default")	
end)

---------------

--serverscript; this script is in ServerScriptService

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local replicateGrip = ReplicatedStorage:FindFirstChild("replicateGrip")

replicateGrip.OnServerEvent:Connect(function(plr, _tool, toolPos)
	replicateGrip:FireAllClients(_tool, toolPos) --sword ref from client script is being passed to all clients
end)

I’m not sure what I did wrong here. I used :FireAllClients(), but only the client that fired the server is able to see the change. This issue also seems to be specific to tool grip related properties; changing any other property in the OnClientEvent() listener (tooltip, name, etc.) would replicate to every client, but changing any property related to the tool grip would not. I’m kind of at a loss here–is there anything I can do?

EDIT: Here’s the file. The tool is placed in StarterPack:
toolgrip.rbxl (19.6 KB)

EDIT 2: Thanks to @BILI1 for helping me out for this!

1 Like

Relocate the client replication into StarterPlayerScripts. Other clients couldn’t see the changes, because the replication in the localscript was rendered only for the tool user.

Tried that just now, but it still doesn’t replicate to other clients. I might have misunderstood, though; I moved the OnClientEvent() listener to StarterPlayerScripts if that was what you meant.

I double-checked your script, and apparently a capitalization error in the server script prevented it from working correctly. Try retyping (“ReplicatedGrip”) in the server script, and let me know if it works.

1 Like

Thanks, I didn’t catch that! Strangely, it still doesn’t work and nothing shows up in the dev console–I’ll post a file in the original post soon, since I’m not sure what else the problem could be

Thank you for linking the file. As unlikely as it seemed, turns out the grip changes only apply accordingly in the user’s screen. I did a workaround, and the grip replication functioned correctly.

replicateGrip.OnClientEvent:Connect(function(_tool, toolPos)
	changeGrip(_tool, toolPos)
	
	if _tool.Parent ~= plr.Backpack and _tool.Parent ~= plr.Character then -- if this isn't the player's character;
		if _tool.Parent:findFirstChild ("Humanoid") then
			local weld = _tool.Parent["Right Arm"]:findFirstChild ("RightGrip")
			if weld then
				weld.C1 = _tool.Grip -- sets the grip weld's inverse as the tool's grip
			end
		end
	end
end)

This is what I thought that seemed to work similarly to how the Tool.Grip changes appeared to the user.
As shown, if it indicates that it’s equipped and finds the user’s RightGrip weld, it sets the RightGrip weld’s inverse to _tool.Grip.

I edited the file a bit in your favour. I made a LocalScript in StarterPlayerScripts and moved your grip replication code there. Here’s the .rbxl: toolgrip.rbxl (20.6 KB)

1 Like

Thank you, this was really helpful! I’ll be sure to mark this as the solution soon ^^

1 Like