hello!! (again... sorry im asking so many questions lol im a bit new to scripting)
I have a custom StarterCharacter in my game who've I've nicknamed Hero. Hero's face has different decals on it for different facial expressions (sad, happy, etc.)
I want to use a remote event so that, when you click a Text Button on your gui, your face changes, and everyone else can see that it changed too, rather than it just being local.
I watched a few tutorials but I'm... still having a lot of trouble.
here's my server script:
game.ReplicatedStorage.RE.OnServerEvent:Connect(function(player) script.Parent.Parent.Character.Mouth.Hero_Mouth.Transparency = 1 print ("your face changed!") end)
and my local script:
script.Parent.MouseButton1Click:Connect(function() game.ReplicatedStorage.RE:FireServer() end)
I know its a problem with how I'm trying to access the player's mouth/face, but I'm not sure how to fix it. I'm trying to make it so that, when someone clicks, for example, a button labelled "happy face," their character's face will switch to the happy decal, and everyone else can see that their character's face has changed to happy as well. im not very experienced with remote events yet, so i probably sound kind of stupid, but can someone help? thank you!!
Ok so what I think it is, is that you put "script.Parent.Parent" and what that is basically telling it to do is reference the Parent of script which is ServerScriptservice, and then the Parent of ServerScriptService which is game because it's a service, and about all services have game as their parent. Obviously, your character is in game, but it's in the player's StarterCharacter (I'm guessing) OR it could be in workspace. So instead of this:
game.ReplicatedStorage.RE.OnServerEvent:Connect(function(player) script.Parent.Parent.Character.Mouth.Hero_Mouth.Transparency = 1 print ("your face changed!") end)
You'd do this to reference your character:
game.ReplicatedStorage.RE.OnServerEvent:Connect(function(player) player.Character.Mouth.Hero_Mouth.Transparency = 1 print ("your face changed!") end)
I put "player" instead of "script.Parent.Parent" because when declaring the function when the remote fires, it passes a parameter called "player", and the first parameter usually specifies the player that fired the remote. I wrote this as IF your character was in the player's StarterCharacter. I am NOT the best at scripting, so if I'm wrong feel free to correct me.