So i wanna make a spawning unit system using remote function. But in client when i pressed the button they doesn’t works and not giving me any errors
-- MODULE SCRIPT (Server script Service)
function Unit.SpawnUnit(player,NewUnit)
local allowed = Unit.Check(player,NewUnit)
if allowed then
local SpawnedUnit = RS.Units[NewUnit]:Clone()
SpawnedUnit.Parent = workspace.Unit
for i,object in ipairs(SpawnedUnit:GetDescendants()) do
if object:IsA("MeshPart") or object:IsA("Part") or object:IsA("UnionOperation") then
object.CollisionGroup = "Units"
end
end
return SpawnedUnit
else
return false
end
end
SpawnFunction.OnServerInvoke = Unit.SpawnUnit
return Unit
Local script:
-- LOCAL
local spawnedtower = nil
ButtonGui.Activated:Connect(function()
if not db then
spawnedtower = ButtonGui.Name
local allowed = requestFunc:InvokeServer(spawnedtower)
if allowed then
local spawned = spawnUnitFunc:InvokeServer(spawnedtower)
if spawned then
print("spawned unit")
end
end