Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Script only shows on one player's computer. What am I doing wrong?

I made a script that changes the appearance of the character but the character does not change on another players computer. This is my code as below

local player = game.Players.LocalPlayer
local color = BrickColor.new('Pastel brown')

script.Parent.MouseButton1Down:connect(function()
    if player.Character then
        for i,v in pairs(player.Character:GetChildren()) do
            if v:IsA('BasePart') then v.BrickColor = color end
        end
    end
end)

local player = game.Players.LocalPlayer


script.Parent.MouseButton1Down:connect(function()

if player.Character:findFirstChild("Shirt") then
player.Character.Shirt.ShirtTemplate="http://www.roblox.com/asset/?id=202704957"
else
local s = Instance.new("Shirt", player.Character)
s.ShirtTemplate="http://www.roblox.com/asset/?id=202704957"
end

if player.Character:findFirstChild("Pants") then
player.Character.Pants.PantsTemplate="http://www.roblox.com/asset/?id=204058688"
else
local p = Instance.new("Pants", player.Character)
player.Character.Pants.PantsTemplate="http://www.roblox.com/asset/?id=204058688"
end

end)

1 answer

✓ Accepted answer

I don't quite understand why you defined player twice. The problem may be that FilteringEnabled is on and that you're using a localscript to perform this. Try replacing the LocalScript with a Script and entering this code in the Script.

function getPlr()
	for i, v in pairs(game.Players:GetPlayers()) do
		if script.Parent:IsDescendantOf(v) then
			return v
		end
	end
end

local player = getPlr()
local color = BrickColor.new('Pastel brown')

script.Parent.MouseButton1Down:connect(function()
    if player.Character then
        for i,v in pairs(player.Character:GetChildren()) do
            if v:IsA('BasePart') then v.BrickColor = color end
        end
    end
end)

script.Parent.MouseButton1Down:connect(function()

if player.Character:findFirstChild("Shirt") then
player.Character.Shirt.ShirtTemplate="http://www.roblox.com/asset/?id=202704957"
else
local s = Instance.new("Shirt", player.Character)
s.Name = "Shirt"
s.ShirtTemplate="http://www.roblox.com/asset/?id=202704957"
end

if player.Character:findFirstChild("Pants") then
player.Character.Pants.PantsTemplate="http://www.roblox.com/asset/?id=204058688"
else
local p = Instance.new("Pants", player.Character)
p.Name = "Pants"
player.Character.Pants.PantsTemplate="http://www.roblox.com/asset/?id=204058688"
end

end)

It should work.

1 comment

0

It does not. It only changes skin color but not the clothing

This discussion is preserved as it was. New answers, comments, and votes are closed.