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
5 years ago

Local script located in StarterGui:

wait()
local DemFormsEvent = game.Workspace.DemFormsEvent
local jun = game.Players.LocalPlayer

jun.Chatted:connect(function(Msg)
local msg = Msg:lower()
if string.sub(msg, 1, 7) == "demon1" then
wait(0.1)
DemFormsEvent:FireServer()
end
if string.sub(msg, 1, 13) == "dem1" then
wait(0.1)
DemFormsEvent:FireServer()
end
if string.sub(msg, 1, 6) == "/e dem1" then
wait(0.1)
DemFormsEvent:FireServer()
end
end)

Server script located in a RemoteEvent in workspace:

wait()
local DemFormsEvent = script.Parent

DemFormsEvent.OnServerEvent:connect(function(player)


    print(player.Name , "Wants to transform")
    local jun = game.Players.LocalPlayer


    local demm1 = Instance.new("Decal")
demm1.Name = "demm1"
demm1.Texture = game.ReplicatedStorage.Dem1.Texture
demm1.Face = game.ReplicatedStorage.Dem1.Face
demm1.Parent = jun.Character.Head
demm1.Color3 = game.ReplicatedStorage.Dem1.Color3


local dema = Instance.new("ParticleEmitter")
dema.Texture = game.ReplicatedStorage.dema.Texture
dema.Color = game.ReplicatedStorage.dema.Color
dema.Rate = game.ReplicatedStorage.dema.Rate
dema.SpreadAngle = game.ReplicatedStorage.dema.SpreadAngle
dema.Speed = game.ReplicatedStorage.dema.Speed
dema.Size = game.ReplicatedStorage.dema.Size
dema.Parent = jun.Character:FindFirstChild("UpperTorso")
wait(2)
dema:Destroy()

local aura = Instance.new("ParticleEmitter")
aura.Name = "aura"
aura.Parent = jun.Character.RightFoot
aura.Size = game.ReplicatedStorage.dem1a.Size
aura.Texture = game.ReplicatedStorage.dem1a.Texture
aura.LightEmission = game.ReplicatedStorage.dem1a.LightEmission
aura.Speed = game.ReplicatedStorage.dem1a.Speed
aura.SpreadAngle = game.ReplicatedStorage.dem1a.SpreadAngle
aura.Rate = game.ReplicatedStorage.dem1a.Rate
aura.Color = game.ReplicatedStorage.dem1a.Color
aura.Lifetime = game.ReplicatedStorage.dem1a.Lifetime
aura.LockedToPart = true

local aura2 = Instance.new("ParticleEmitter")
aura2.Name = "aura2"
aura2.Parent = jun.Character.LeftFoot
aura2.Size = game.ReplicatedStorage.dem1a.Size
aura2.Texture = game.ReplicatedStorage.dem1a.Texture
aura2.LightEmission = game.ReplicatedStorage.dem1a.LightEmission
aura2.Speed = game.ReplicatedStorage.dem1a.Speed
aura2.SpreadAngle = game.ReplicatedStorage.dem1a.SpreadAngle
aura2.Rate = game.ReplicatedStorage.dem1a.Rate
aura2.Color = game.ReplicatedStorage.dem1a.Color
aura2.Lifetime = game.ReplicatedStorage.dem1a.Lifetime
aura2.LockedToPart = true


end)

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 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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

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.

Ad

Answer this question