Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Tool can not be soon by other players?

Asked by 5 years ago
Edited 5 years ago

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!

0
yes, due to network filtering, you have to give the tool on the server theking48989987 2147 — 5y
0
It appears you have used `:connect()` use `:Connect` may not help now but in the future... well that will break. WideSteal321 773 — 5y
0
Alright, how would I give it on the server? I already know you make a event and fire it, but I'm not sure what to put in that script. InfiniteWhileLoop 19 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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.

0
(Same comment as above lol) Alright, how would I give it on the server? I already know you make a event and fire it, but I'm not sure what to put in that script. InfiniteWhileLoop 19 — 5y
0
I don't know the details. I would help, but I gtg. RetroGalacticGamer 331 — 5y
Ad

Answer this question