Studio Test Equiped Tool Not Showing On Server

i have some problems with getting my players equiped tool to show on the server.
i had previously had the equip process done in a player localscript but as that did not fix this I have put the equip code in a module hoping that as that would be running on the server it would be a solution.
It did not work as shown in this pic.
Roblox_EquipedToolNotShowingOnServer

The invoke in the localscript now is

_G.Controller.Equipped:Connect(function()
	CM:Disable()	-- freez player
	equiping.Visible = true
	print("Equiped")
	_G.Controller = script.Parent
        local BMEquiped = ControllerBMModuleScript:Equip(ActivePlayer)
	if BMEquiped then
		holding = true
	end
	CM:Enable() -- unfreez player
end)

and the corresponding code in the module is

-- This module manages BotMaster equip.

local module = {}

local parts = {}

local function scanWeld(parent,Bot)
	for _,v in pairs(parent:GetChildren()) do
		if (v:IsA("BasePart")) then
			if v.Name ~= "MainPart" then
				local w = Instance.new("WeldConstraint")
				w.Name = ("WC_%s"):format(v.Name)
				w.Part0 = Bot.MainPart
				w.Part1 = v
				w.Parent = Bot.MainPart
				table.insert(parts,v)
				scanWeld(v)
				wait(0.05)
			end
		end
	end
end



function module:Equip(player)
	print("BM_Equip_Called")
	local BotMasterOffset = Vector3.new(-0.5,0,-1.75)
	local BotMasterOrientation = CFrame.Angles(0,0,math.rad(90))
	
	local RS = game:GetService("ReplicatedStorage")
	local Players = game:GetService("Players")
	local LP = Players.LocalPlayer
	local Handle = _G.Controller:WaitForChild("Handle")
	local Bot = RS.BotMaster:Clone()
	Bot.Parent = Handle
	scanWeld(Bot, Bot)
	for _,v in pairs(parts) do
		v.Anchored = false
	end
	parts = {}
	local APUTCF = player.UpperTorso.CFrame
	local BotMainPartCFrameAdjustment = APUTCF + APUTCF.lookVector + BotMasterOffset
	Bot:SetPrimaryPartCFrame(BotMainPartCFrameAdjustment)
	local orientBot = Bot:GetPrimaryPartCFrame() * BotMasterOrientation 
	Bot:SetPrimaryPartCFrame(orientBot)

	local w1 = Instance.new("WeldConstraint")
	w1.Part0 = player.UpperTorso
	w1.Part1 = Bot.MainPart
	w1.Name = "WC_BotMaster"
	w1.Parent = player.UpperTorso

	Bot.MainPart.Anchored = false

	wait(0.1)
	local color1 = Color3.new(0,0,0.5)
	local color2 = Color3.new(0,0,0.75)
	local colorSeq = ColorSequence.new(color1,color2)
	local beam = Instance.new("Beam")
	beam.FaceCamera = true
	beam.Attachment0 = player.UpperTorso.BodyFrontAttachment
	beam.Width0 = 0.075
	beam.Attachment1 = Bot.BackShield.Attachment
	beam.Width1 = 0.075
	beam.Color = colorSeq
	beam.Name = "Beam_BotMaster"
	beam.Parent = player.UpperTorso
	return true
end


return module

So my question is how do I get the tool to show in the server so that when I go to multi-player I see all the players with their tools in each players window.

I suppose that both provided scripts are local, right? You need a server script to actually make anything show up for others.

That’s not how modules work. They don’t just run on the server, they operate on behalf of which script required it.
You should use a server-sided script in conjunction with RemoteEvents to send any data to the server if needed.

Rule of thumb:

  • If you want it to appear for everyone, use a server script (with some exceptions)
  • For things like effects or user input, consider using a local script

Edit: edited link to a tutorial rather than the documentation

1 Like

Could I use RemoteFunctions or is it only RemoteEvents?

RemoteFunctions are used if you need a return value, or if you just want a confirmation that the request was successful. RemoteEvents just send data in one way. In your case, RemoteFunctions would be required if you wanted to make high quality models show up on client’s side only, but since you don’t have that, you don’t need it.

You could use RemoteFunctions, but that would needlessly increase the traffic.

ok, so. got further on. Now using ServerFunction and the invocation is activated but I hit a snag with my use of global variables which it appears ServerFunctions don’t like.
I can code round that in this part which is the Tool by either passing a reference through the invocation or doing a FindFirstChild as I know its name which will solve this particular topic.
I have a follow on problem which is a side effect of using this solution and my use of global variables and I will create another topic for that once I have had a go at solving it myself.
Thank you.

All you have to do is put the code that makes the ‘stuff’ appear, and place it into a server script, surrounded by this:

--Example. You replace the directory with where you have your remote event
game.ReplicatedStorage.Remotes.ServerEquip.OnServerEvent:Connect(Player,--[[Any subsequent arguments]])
    --Code goes here
end

In your local script, you will need to fire the remote event in order for the above server code to run:

game.ReplicatedStorage.Remotes.ServerEquip:FireServer(--[[Any arguments you might want to pass]])

Hope this somewhat helps

1 Like

I have succeeded in getting this done and now understand more about the client/server structure and the links between them.
I used ServerFunction as I needed to confirm completion.