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

Cannot change character's physical traits?

Asked by 6 years ago
Edited 6 years ago

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!!

0
Ok, it's just gonna be invisible like that? WideSteal321 773 — 6y
0
Well, its gonna change to a different decal later on. Im just making it invisible for now and then Ill actually have it change when I actually manage to get the script to work. yoshikins101 11 — 6y
0
Ok. WideSteal321 773 — 6y
0
if I can ask, where exactly is the server script? ihatecars100 502 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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.

0
Oh! the answer was so simple and i never realized lol. thank you so much! yoshikins101 11 — 6y
0
np Be_Happy1373 32 — 6y
Ad

Answer this question