Greetings all,
I’m attempting to pass an Instance through a remote function. For most people, using ReplicatedStorage would be fine to fetch these. However, I am storing weaponry in ServerScriptService and need the models themselves for display purposes in viewports. I could just make alternative versions of them and place them in ReplicatedStorage as well.
The reasoning for keeping them on the server though is to reduce exploitation. Yes I understand the minute I put it onto the client it becomes available to them though.
The question is, how could I pass an entire tool through to the client? I have this so far, but it errors out.
-- Client
local toolModel = game.ReplicatedStorage.Triggers.getWeaponTool("Melee", melee.serverName)
-- Server
function fetchWeaponModel(player, category, weapon)
if checkHost(player) then
local toolModel
for _, tool in pairs(game.ServerStorage.Weapons[category][weapon].StarterPack:GetChildren()) do
if tool:IsA("Tool") then
local toolClone = tool:Clone()
for _, children in pairs(toolClone:GetChildren()) do
if children:IsA("LocalScript") or children:IsA("Script") then
children:Destroy()
end
end
toolModel = toolClone
end
end
return toolModel
end
end
game.ReplicatedStorage.Triggers.getWeaponTool.OnServerInvoke = fetchWeaponModel
Any ideas or thoughts?