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!