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

Why my metatable doesn't found my object?

Asked by 4 years ago
Edited 4 years ago

I want found a object on ReplicatedStorage selected by the client on a UI. I have two folders with my models inside. I want if the model isn't in the first folder the script search on the second.

ClientScript

local PlayerService = game:GetService('Players')
local RStorageService = game:GetService('ReplicatedStorage')

script.Parent.TextButton.MouseButton1Click:Connect(function()
    game:GetService('ReplicatedStorage').RemoteEvent:FireServer(RStorageService.CivilSet.Head.Default.Name)
end)

ServerScript

local RStorageService = game:GetService('ReplicatedStorage')

local heads = setmetatable(RStorageService.VampireSet.Head:GetChildren(), {
    __index = RStorageService.CivilSet.Head:GetChildren()
})


local function hatsFitter(Player, Model)
    local head = heads[Model]:Clone()

    head.Parent = workspace
end

RStorageService.OnServerEvent:Connect(hatsFitter)

THIS IS A EXEMPLE OF MY REAL SCRIPT

Answer this question