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

How to make players respawn with certain meshes?

Asked by 6 years ago

The problem i have with this is they spawn with the correct meshes (I have inside serverstorage that gets cloned to the players character) but when they respawn it doesn't add it to them. The problem only occurs for players who have character meshes. If somebody doesnt have meshes then when they respawn they get given the meshes I have. If they have meshes for their character (such as robloxian 2.0, etc) then it just loads them as theirselves.

Is there a way to wait for their own meshes to load, then remove them? Or to make it so every player doesnt have a mesh, but they keep their clothing, hats, etc.?

2 answers

Log in to vote
0
Answered by 6 years ago

You have to clone the Mesh everytime they respawn:

--Put this script in ServerScriptStorage

local Storage = game:GetService('ServerStorage')
local Mesh = Storage:WaitForChild("My Mesh")
game.Players.PlayerAdded:connect(plr)
    plr.CharacterAdded:connect(char)
        local NewMesh = Mesh:Clone()
        NewMesh.Parent = char.SomeWhere
    end)
end)
0
Thats what im doing. The problem is it clones the mesh into the player, then the players normal meshes are created, thus removing the ones i put in the player. I need a way to wait for the players original meshes to load before giving them the ones i have stored NinjoOnline 1146 — 6y
Ad
Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
6 years ago

You can add a whitelist.


local player = game.Players.LocalPlayer local ReplicatedStorage = game:GetService('ReplicatedStorage') local character = player.Character or player.CharacterAdded:wait() local banned = 'CharacterMesh' local meshes = ReplicatedStorage:WaitForChild('Folder') local whiteList = { meshname1 = true, meshname2 = true, meshname3 = true } --[[ this has the potential to fail because of you loading before the objects for i,v in pairs(meshes:GetChildren()) do -- populate whiteList[v.Name] = v end --]] function delete(obj) if obj.ClassName == banned or obj.Name == banned then if not whiteList[obj.Name] then game.Debris:AddItem(obj, 1/30) print("Deleted: " ..obj.Name) end end end character.DescendantAdded:connect(function(obj) -- If anything gets added as we load or after, check it. delete(obj) end) -- if the script loads after we load for whatever reason -- loops through every Instance in character local function recur(obj) for i,v in pairs(obj:GetChildren()) do delete(v) recur(v) end end recur(character)

Answer this question