#model has no name property?

1 messages · Page 1 of 1 (latest)

little yew
#

i was making data save stuff and when i run this function providing the player and model to switch with, it brings up this error.
can someone explain whats going on here?

code:

local Swap = function(player,model)
    if model == nil then return end
    -- Things
    local CurrentChar = player.Character
    local char = model:Clone()
    local savename = player.Name
    local pos = player.Character.HumanoidRootPart.CFrame
    local Health = game.ReplicatedStorage.Swap_Things.HealthBar:Clone()
    local Inv = player.Backpack:Clone()
    local TrollV = player:FindFirstChild("Trollge")


    -- Set Char
    TrollV.Value = model.Name
    char.Name = savename -- error is here
    player.Character:Destroy()
    player.Character = char
    char.Parent = workspace
    char.HumanoidRootPart.CFrame = pos
    Health.Parent = char
    Health.Script.Enabled = true
    for i,v in player.Backpack:GetChildren() do
        v:Destroy()
    end
    for i,v in Inv:GetChildren() do
        if v:HasTag("Weapon") then continue end
        v.Parent = player.Backpack
    end
    Inv:Destroy()
end
#

this is what im giving it lua game.Players.LocalPlayer,game.ReplicatedStorage.Chars:FindFirstChild(game.Players.LocalPlayer:WaitForChild("Trollge").Value

bleak wyvern
little yew
#

then would it not say savename instead?

bleak wyvern
#

because it's not referring to that var, it's referring to char

little yew
#

huh

#

the the char is the model'

#

savename is the player instance name

bleak wyvern
#

char is nil

little yew
#

oh

bleak wyvern
#

(If you pointed to the right line)

#

But if that's actually line 18 then it's char, that is nil

cinder pasture
#

Look into the property called Archivable @little yew

#

I believe that is the root of all evils for u

little yew
#

i think char might be a string

#

bc when i print what its sending it has the right model name

cinder pasture
#

It does that if you print an instance as well

little yew
#

yeah

#

its not a string

#

so idk what going on

#

char is nil it says

#

but im giving an instance

little yew
#

ok now it works in sudio.. BUT NOT IN GAME

#

why 😭😭😭

meager elbow
#

cuz in studio you're the server and is probably loading faster

#

you're just indexing in all the properties like that

#

do some checks bro