Local script located in StarterGui:
01 | wait() |
02 | local DemFormsEvent = game.Workspace.DemFormsEvent |
03 | local jun = game.Players.LocalPlayer |
04 |
05 | jun.Chatted:connect( function (Msg) |
06 | local msg = Msg:lower() |
07 | if string.sub(msg, 1 , 7 ) = = "demon1" then |
08 | wait( 0.1 ) |
09 | DemFormsEvent:FireServer() |
10 | end |
11 | if string.sub(msg, 1 , 13 ) = = "dem1" then |
12 | wait( 0.1 ) |
13 | DemFormsEvent:FireServer() |
14 | end |
15 | if string.sub(msg, 1 , 6 ) = = "/e dem1" then |
16 | wait( 0.1 ) |
17 | DemFormsEvent:FireServer() |
18 | end |
19 | end ) |
Server script located in a RemoteEvent in workspace:
01 | wait() |
02 | local DemFormsEvent = script.Parent |
03 |
04 | DemFormsEvent.OnServerEvent:connect( function (player) |
05 |
06 |
07 | print (player.Name , "Wants to transform" ) |
08 | local jun = game.Players.LocalPlayer |
09 |
10 |
11 | local demm 1 = Instance.new( "Decal" ) |
12 | demm 1. Name = "demm1" |
13 | demm 1. Texture = game.ReplicatedStorage.Dem 1. Texture |
14 | demm 1. Face = game.ReplicatedStorage.Dem 1. Face |
15 | demm 1. Parent = jun.Character.Head |
I am still learning about Remote events etc. so don't be rude if i made a ridiculous mistake. I would appreciate some help to learn as fast as possible!
At line 8 in the server script, you attempt to assign the LocalPlayer to a variable:
1 | local jun = game.Players.LocalPlayer |
If this is really a server script, then there is no LocalPlayer. You don't need that anyway. You already have the player
variable passed to the function.
Note: :connect
is deprecated, use :Connect
. You can also use workspace
instead of game.Workspace
.