Grass that when touched makes you invisible acts differently on server

So I’m working on a moba, and I’m working on an aspect from the genre which is grass. Basically this is how it goes:

Player walks into grass
They appear invisible to everyone, but to the player themselves they’re only partially invisible
Player exits grass
Visible again

It seems to work fine when I play it in studio like so:

But when I test it in a server, this happens:

This is the server code, it’s in a module script. It’s called by Touched Events.

function Grass.Transparency(Character, Transparency, ChangePlayerTransparency)
    for _, part in pairs(Character:GetChildren()) do
	    if part:IsA("Accessory") then
		    part.Handle.Transparency = Transparency else if part:IsA("MeshPart") then
		        	part.Transparency = Transparency else if part:IsA("Part") then
				    part.Transparency = Transparency
			    end
		    end
	    end
    end
    Character.Head.face.Transparency = Transparency
    Character.HumanoidRootPart.Transparency = 1
    if Transparency == 1 then
	    ChangePlayerTransparency:FireClient(Character.Parent, Transparency)
    end
end

This is the client side code.

ChangePlayerTransparency.OnClientEvent:Connect(function(Transparency)
for _, part in pairs(Character:GetChildren()) do
	if part:IsA("Accessory") then
		part.Handle.Transparency = .7 else if part:IsA("MeshPart") then
			part.Transparency = .7 else if part:IsA("Part") then
				part.Transparency = .7
			end
		end
	end
end
Character.Head.face.Transparency = .7
Character.HumanoidRootPart.Transparency = 1

end)

The game is filtering enabled, so I’m really unsure why it’s acting like this and would appreciate any help!

2 Likes

This is the issue, try using this line of code instead:

ChangePlayerTransparency:FireClient(game.Players:GetPlayerFromCharacter(Character), Transparency)

In your original code you are calling the player’s Character, instead of their player object.

That fix works! Thank you!

Do you know why it worked when I played in studio, but not in an actual server?

FireClient is probably hardcoded to just fire in studio.

1 Like