Hello, I am working on a game with a friend and he made this script and only your client can see the tool, I am not sure how to fix it and I have asked him a lot to fix it and he wont so I am trying to figure it out myself. The script works 100%, but the tool cannot be seen by other players. Do you have to give the tool to the player on the server? Here's the script:
local Pizzas = {} local Buttons = {} local Equipped = nil game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false) local Player = game.Players.LocalPlayer local Character = Player.Character local function search(location) for i,v in pairs(location:GetChildren()) do if v:IsA("Tool") then table.insert(Pizzas,v) end end end function update() for i,v in pairs(Buttons) do v:Destroy() end for i,v in pairs(Pizzas) do local Sample = script.Sample:Clone() Sample.Name = v.Name Sample.Image = v.TextureId Sample.Parent = script.Parent.MainFrame.Handler table.insert(Buttons,Sample) if Equipped ~= nil and Equipped == v then Sample.Equipped.Visible = true end Sample.MouseButton1Click:connect(function() if Equipped == nil or Equipped ~= v then Equipped = v Character.Humanoid:UnequipTools() Character.Humanoid:EquipTool(v) else Equipped = nil Character.Humanoid:UnequipTools() end end) end end function refresh() Pizzas = {} search(Character) search(Player.Backpack) update() end refresh() Player.Backpack.ChildAdded:connect(refresh) Player.Backpack.ChildRemoved:connect(refresh) Character.ChildAdded:connect(refresh) Character.ChildRemoved:connect(refresh)
Let me know what is wrong here!
The mistake you are most likely making is putting this code in a local script. See, the client will not replicate to the server, so you need to deliver the tool to the player using a server side script. Just telling you right now, with filteringEnabled you are going to have to get use to using Server Scripts, remoteFunctions and Remote Events, and finally, values.