Tool appears for client but not for server?

wait(1)
local player = game:GetService("Players").LocalPlayer
local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local handle2 = tool:WaitForChild("Handle2")
local CAS = game:GetService("ContextActionService")

local r1 = game.ReplicatedStorage.pShake
local remote = game.ReplicatedStorage.bicep

local character = player.Character
local humanoid = character:FindFirstChild("Humanoid")


local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://5863386806"
local animationTrack = humanoid:LoadAnimation(animation)

local anim2 = Instance.new("Animation")
anim2.AnimationId = "rbxassetid://5872225039"
local animTrack2 = humanoid:LoadAnimation(anim2)

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://5863423998"
local animTrack = humanoid:LoadAnimation(anim)

spawn(function()
	local weld = Instance.new("Weld")
	weld.Parent = handle2
	weld.Part0 = handle2
	weld.Part1 = character:FindFirstChild("LeftHand")
	weld.C0 = CFrame.new(0, 0, .025) * CFrame.Angles(0,89.5,0)
end)

Hello,

When I test this in studio the two dumbbells appear on both hands but when I go into a local server or a team test, the dumbbells appear on both hands but only for the local player. On the server, the second person doesn’t appear to be holding both dumbbells, just one and the second person on their screen sees both dumbbells but not for the first player.

How do I replicate the weld for the server?

2 Likes

It’s because it’s probably a local script. You have to use a script on the server for it to replicate on it. You can use a remote event to call and create it.

1 Like

you soldered it only at the client because the data was not copied to the server.
To overcome this you just need to put the above code in the Script. And added earlier:

local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local handle2 = tool:WaitForChild("Handle2")

I tried creating a RemoteEvent to signal the server to create the weld but then it attaches both the players together, welding their left hands.

Not sure what you mean by “Both the players”? Do you mean it is welding multiple players together instead of the tool?

Sorry, I’m a little confused by what you meant. Do you mean to put:

spawn(function()
	local weld = Instance.new("Weld")
	weld.Parent = handle2
	weld.Part0 = handle2
	weld.Part1 = character:FindFirstChild("LeftHand")
	weld.C0 = CFrame.new(0, 0, .025) * CFrame.Angles(0,89.5,0)
end)

At the top of the script?

Yeah, it’s welding multiple players together almost fusing them. Sorry I wasn’t specific.

Sounds like there is a problem with your welding system. Try and figure out what is causing the script to weld players together instead of tools?

Could you show us what your code looks when moved to the server? Specifically the welding.

Sure! Hopefully I didn’t mess up bad lol

--Local script
wait(1)
local player = game:GetService("Players").LocalPlayer
local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local handle2 = tool:WaitForChild("Handle2")
local CAS = game:GetService("ContextActionService")

local bicepLeft = game.ReplicatedStorage.bicepLeft
local r1 = game.ReplicatedStorage.pShake
local remote = game.ReplicatedStorage.bicep

local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChild("Humanoid")

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://5863386806"
local animationTrack = humanoid:LoadAnimation(animation)

local anim2 = Instance.new("Animation")
anim2.AnimationId = "rbxassetid://5872225039"
local animTrack2 = humanoid:LoadAnimation(anim2)

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://5863423998"
local animTrack = humanoid:LoadAnimation(anim)


bicepLeft:FireServer()

--Server script
local remote = game.ReplicatedStorage.bicepLeft

local handle2 = script.Parent.Handle

remote.OnServerEvent:Connect(function(player)
	local weld = Instance.new("Weld")
	weld.Parent = handle2
	weld.Part0 = handle2
	weld.Part1 = player.Character:FindFirstChild("LeftHand")
	weld.C0 = CFrame.new(-.05, 0, .025) * CFrame.Angles(0,89.5,0)
end)

The problem seems to be with local handle2 = script.Parent.Handle how you use this line in the server.
You need to put it inside the remote call event. And change it so u reference the handle based on the specific characters tool.

It should look like this:

remote.OnServerEvent:Connect(function(player)
        local handle2 = player.Character.ToolName.Handle
	local weld = Instance.new("Weld")
	weld.Parent = handle2
	weld.Part0 = handle2
	weld.Part1 = player.Character:FindFirstChild("LeftHand")
	weld.C0 = CFrame.new(-.05, 0, .025) * CFrame.Angles(0,89.5,0)
end)

So something like this? It’s still welding the players together, almost trying to fuse their bodies

local remote = game.ReplicatedStorage.bicepLeft



remote.OnServerEvent:Connect(function(player)
	local handle2 = script.Parent.Handle
	local weld = Instance.new("Weld")
	weld.Parent = handle2
	weld.Part0 = handle2
	weld.Part1 = player.Character:FindFirstChild("LeftHand")
	weld.C0 = CFrame.new(-.05, 0, .025) * CFrame.Angles(0,89.5,0)
end)

You need to change local handle2 = script.Parent.Handle to local handle2 = player.Character.ToolName.Handle2

Also I wouldn’t suggest placing the server script inside the tool, if the remote is placed elsewhere. As everyone will be firing to the same remote and you’ll have multiple scripts registering the same request.

1 Like

I changed the handle2 but now it’s saying it’s not a valid member of the model. And okay I moved the script to ServerScriptService, thank you for letting me know!

Could u show me what the children of the Tool are. Did you reference it correct, as in is the name of the handle “Handle2”?. Try using a WaitForChild when searching for the handle.

Nevermind I fixed it. I had to change local handle2 = player.Character.Dumbbell.Handle2 to local handle2 = player.Backpack.Dumbbell.Handle2 Now I can see both dumbbells on both screens! Thank you for your help. I marked you as a solution.

That’s great.
Another tip, the reason why the 1st Handle replicates is because of the RequireHandle property of the tool. It would look for a part named Handle and weld the part to your right hand. You can apply the same procedure to the first handle if you disable that property. Though, you should handle the removal of welds/motor6d on server as well when the tool is not equipped.

If you wish to animate with the handles. You’d have to use Motor6D instead of welds.

1 Like

Ah okay that’s interesting. I didn’t know that. I appreciate the tip and I will keep that in mind!

1 Like