Murder Disguise

You can write your topic however you want, but you need to answer these questions:
Trying to make a murderer ability called Disguise where it takes a character from replicatedstorage and changes your disguise

It’s only happening locally, and to everyone else, you become naked and weird.
image
What I see


What the user sees
local used = false

function applyChar(player,char)
for _,e in ipairs(player.Character:GetChildren()) do
if e.className==“Hat” or e.className==“Shirt” or e.className==“Pants” or e.className==“CharacterMesh” then
e:Remove()
end
end
player.Character.Head2:Remove()
for _,e in ipairs(char:GetChildren()) do
if e.Name==“Head” then
local h2 = e:Clone()
h2.Anchored = false
h2.Name = “Head2”
player.Character.Head.Transparency = 1
Instance.new(“Weld”).Parent = h2
h2.Weld.Part0 = player.Character.Head
h2.Weld.Part1 = h2
h2.Parent = player.Character
if h2:FindFirstChild(“face”)~=nil then
player.Character.Head.face.Texture = h2.face.Texture
h2.face:Remove()
end
player.Character.Torso.BrickColor = h2.BrickColor
player.Character[“Right Arm”].BrickColor = h2.BrickColor
player.Character[“Left Arm”].BrickColor = h2.BrickColor
player.Character[“Right Leg”].BrickColor = h2.BrickColor
player.Character[“Left Leg”].BrickColor = h2.BrickColor
if char.Name==“Flinn” then
h2.BrickColor = BrickColor.new(“Light orange”)
end
player.Character.Humanoid.CharName.Value = char.Name
workspace.GameScript.NameGui:Clone().Parent = h2
h2.NameGui.Display.Text = char.Name
h2.NameGui.Display.Visible = true
h2.NameGui.PlayerToHideFrom = player
elseif e.Name==“Handle” then
local hat = Instance.new(“Hat”)
hat.AttachmentPoint = e.CFrame:inverse()(char.Head.CFrameCFrame.new(0,0.5,0))
e:Clone().Parent = hat
hat.Handle.FormFactor = “Custom”
hat.Handle.Size = Vector3.new(0.2,0.2,0.2)
hat.Handle.Anchored = false
hat.Parent = player.Character
else
e:Clone().Parent = player.Character
end
end
end

script.Parent.Selected:connect(function(mouse)
mouse.Icon = “http://www.roblox.com/asset/?id=54019936
mouse.Button1Down:connect(function()
if not used then
used = true
local chars = game.ReplicatedStorage.Characters:GetChildren()
local players = game.Players:GetChildren()
for i=1,#players do
if players[i].Character~=nil and players[i].Character:FindFirstChild(“Humanoid”)~=nil and players[i].Character.Humanoid:FindFirstChild(“CharName”)~=nil then
for n,char in ipairs(chars) do
if char.Name==players[i].Character.Humanoid.CharName.Value then
table.remove(chars,n)
break
end
end
end
end
applyChar(game.Players.LocalPlayer,chars[math.random(1,#chars)])
script.Parent:Remove()
end
end)
end)

.

First, use Destroy().

Second, you are running this on a LocalScript. Changes will not replicate to the server, meaning others will not see your clothing.

1 Like

So then would I use a ModuleScript or a normal Script

Normal Script. ModuleScripts are used for storing functions or/and tables. Read more about them here.

Also note that you have to specify the Player instance using a variable, LocalPlayer is always nil server-sided.

How do i do that? I’m not very smart

I don’t really know, depends on your game’s mechanics.

By the way, a quick way to collect player appearance assets is to use their superclass, CharacterAppearance. You can avoid a long train of ClassName checking and all that.

for _, appearanceItem in ipairs(player.Character:GetChildren()) do
    if appearanceItem:IsA("CharacterAppearance") then
        appearanceItem:Destroy()
    end
end

This can be done for switching in and out of characters. Just make sure that, at the end of the day, you respect the client-server model when approaching this disguise thing. The deletions you initially made replicate but adding more appearance items doesn’t. You’ll need remotes at some step of the way.

1 Like

Can you tell me this in english? I’m still new to this stuff

The code is a little bit unorganized so I didn’t bother taking time to read it… But since you said it’s only happening on the client then you’re probably using a local script. Try to run the event that changes the appearance on a Server Script.

That’s why it’s imperative you do research. This is as English as I can make it. If you don’t understand something, you should always search first before asking a question. All the information and terms I used are searchable and assume a degree of familiarity with programming terms.