Change in character properties only appearing for player

So I’m making a very simple (or so I thought) input script that makes you equip clothing based on a morph already in the character with all the pieces transparent. My script is essentially a LocalScript in PlayerGui that finds those morph pieces and makes them visible upon pressing Q.

My question is why does it only become visible for me? I had a friend join a test server and we both couldn’t see each others morph become solid.

Here’s my code

local player = game.Players.LocalPlayer or game.Players.PlayerAdded.Wait()
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local uis = game:GetService("UserInputService")
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://7114685627"

function onKeyPressed(inputObject, gameProcessEvent)
	if inputObject.KeyCode == Enum.KeyCode.Q then
		humanoid:LoadAnimation(anim):Play()
		wait (2)
		character.Chest1.A.Transparency = 0
		wait (0.5)
		character.Chest2.B.Transparency = 0
		print("Visible")
		script:Destroy()
	end
end

uis.InputBegan:Connect(onKeyPressed)

Being new to scripting I’m sure there’s an easy fix I’m just not understanding so thank you for any help and / or lessons given!

Any changes that you make through a LocalScript will only affect the client that the LocalScript is assigned to. In order to control something on the Server (all clients will see) through the Client, you need to consider using RemoteEvents

load animations in the animator which is a child of the humanoid so it replicates for other players

That isn’t their only issue though, they are also trying to set the transparency of some parts of their vest (I’m guessing it’s as vest), so they still need to use a RemoteEvent

yeah noticed it but you pointed it out above

Animations are visible to all players - only the transparent pieces that aren’t changing.

Is there an easy way to implement this into my given code? I’ve looked through the page and tried a few integrations but I’m having no luck with it. Thanks for identifying the issue!

Give me a minute. I’ll write something simple for you (will require another script)

1 Like

this is to why to load it into the animator

In your current LocalScript, make these changes:

local player = game.Players.LocalPlayer or game.Players.PlayerAdded.Wait()
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local uis = game:GetService("UserInputService")
local anim = Instance.new("Animation")
local event = game.ReplicatedStorage:WaitForChild("ChestEvent")
anim.AnimationId = "rbxassetid://7114685627"

function onKeyPressed(inputObject, gameProcessEvent)
	if inputObject.KeyCode == Enum.KeyCode.Q then
		humanoid:LoadAnimation(anim):Play()
		wait (2)
		event:FireServer()
		script:Destroy()
	end
end

uis.InputBegan:Connect(onKeyPressed)

In a new Script (not LocalScript), preferably in ServerScriptService, please add this code:

local event = Instance.new("RemoteEvent")
event.Name = "ChestEvent"
event.Parent = game.ReplicatedStorage

event.OnServerEvent:Connect(function(player)
    local character = player.Character
    if character then
        character.Chest1.A.Transparency = 0
        wait (0.5)
        character.Chest2.B.Transparency = 0
    end
end)
2 Likes
game.ReplicatedStorage.Visible.OnServerEvent:Connect(function(player)
	for _,v in pairs(player.Character:GetChildren()) do
		if v:IsA("BasePart") then
			v.Transparency = 0
			v.Parent.HumanoidRootPart.Transparency = 1
		end
	end
end)

This worked perfectly - thanks so much for your help!