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

The scripts only work in the studio, but not in the actual game, how do i fix them?

Asked by
Echtic 128
6 years ago

Local script located in StarterGui:

01wait()
02local DemFormsEvent = game.Workspace.DemFormsEvent
03local jun = game.Players.LocalPlayer
04 
05jun.Chatted:connect(function(Msg)
06local msg = Msg:lower()
07if string.sub(msg, 1, 7) == "demon1" then
08wait(0.1)
09DemFormsEvent:FireServer()
10end
11if string.sub(msg, 1, 13) == "dem1" then
12wait(0.1)
13DemFormsEvent:FireServer()
14end
15if string.sub(msg, 1, 6) == "/e dem1" then
16wait(0.1)
17DemFormsEvent:FireServer()
18end
19end)

Server script located in a RemoteEvent in workspace:

01wait()
02local DemFormsEvent = script.Parent
03 
04DemFormsEvent.OnServerEvent:connect(function(player)
05 
06 
07    print(player.Name , "Wants to transform")
08    local jun = game.Players.LocalPlayer
09 
10 
11    local demm1 = Instance.new("Decal")
12demm1.Name = "demm1"
13demm1.Texture = game.ReplicatedStorage.Dem1.Texture
14demm1.Face = game.ReplicatedStorage.Dem1.Face
15demm1.Parent = jun.Character.Head
View all 57 lines...

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!

0
fix indentation Programical 653 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

At line 8 in the server script, you attempt to assign the LocalPlayer to a variable:

1local 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.

Ad

Answer this question