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

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

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago

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.

0
It does not. It only changes skin color but not the clothing Relampago1204 73 — 9y
Ad

Answer this question