Model cloned in ReplicatedStorage gives bizarre type checking warnings

This should probably be a bug report, but i cant post those lol (also my first post).

These warnings seemingly appeared overnight, as my scripts were generating no warnings last night.
Type checking seems to view Models cloned in ReplicatedStorage as a different type then the usual Model type, which causes some really strange warnings.

Below is an example script demonstrating the warnings; I have a Model in ReplicatedStorage that is cloned.

--!strict

-- Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PlayerService = game:GetService("Players")

-- Service variables
local Rig = ReplicatedStorage.Rig -- Model

-- Module
local Module = {}
local Meta = {
  __index = Module
}

-- Types
type CharacterBase = {
  Rig: Model,
  Player: Player
}

type Character = typeof(setmetatable({} :: CharacterBase, Meta))

-- Public functions
function Module.new(Player: Player): Character
  local CharacterRig = Rig:Clone() -- Adding ::Model or :Model fixes the second and third warning, but not the first

  CharacterRig.Name = Player.UserId -- Warn here ('number' could not be converted into 'string')
  CharacterRig.Parent = workspace -- Warn here ('Workspace' could not be converted into 'ReplicatedStorage')
  
  local Character: Character = setmetatable({ -- Warn here (entire block)
    Rig = CharacterRig, -- Type 'Model' from 'DataModel' could not be converted into 'Model' from 'Roblox'
    Player = Player
  }, Meta)

  return Character
end

-- Connections
PlayerService.PlayerAdded:Connect(Module.new)

Line 31-34 give me the weirdest warning:
image

Even stranger is that moving the model to be cloned under the script itself completely removes all the the type checking warnings. In both contexts the scripts compile just fine.

I’m at a lost as of how to fix these warnings in my game. If anyone has any advice, please do tell.

Repro: bizzare_type_checking.rbxl (73.1 KB) (Scripts are located in ServerScriptService)

2 Likes

I’m not quite sure why you’re getting that error, but why use metatables for this??? Seems overly complicated.

1 Like

It’s a condensed version of a script I’m using in a normal game, I just removed most of the object functions. Removing the metatables fixes the 'Model' from 'DataModel' could not be converted into 'Model' from 'Roblox' warn but not the others.

2 Likes

Been getting some weird type checks too. Like this, LOL:

image
image

Yeah, it seems like Players.LocalPlayer was turned into Player? and workspace.CurrentCamera was turned into Camera?, which causes a lot of warnings within my scripts. Player.PlayerGui also gives a warning now, not sure what happened.

2 Likes

Seems like these bugs were fixed overnight, not getting any more warnings.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.