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

Why does "Admin" only get put into ServerScriptService in Studio, but not real game?

Asked by 7 years ago

This is a Script in game.Workspace:

game.Players.PlayerAdded:connect(function(Player)

local SSS = game:GetService("ServerScriptService")
game:WaitForChild("ServerScriptService")

Player:WaitForChild("PlayerGui")

local PlayerGui = Player.PlayerGui

local AM = script.Admin
AM.Parent = game.ServerScriptService
AM.Disabled = false

local c = script.Login:Clone()
c.Parent = PlayerGui

end)

And this is a LocalScript that gets cloned to game.Players.PLR.PlayerGui.Login.PassBox:

script.Parent:TweenPosition(UDim2.new(0.5, -227, 0.5, -60))

script.Parent.Exit.MouseButton1Click:connect(function()
    script.Parent:TweenPosition(UDim2.new(0.5, -227, 2, 0))
    wait(1)
    script.Parent.Parent:Destroy()
end)

script.Parent.Login.MouseButton1Click:connect(function()
    local LoginVal = game.ServerScriptService.Admin.Login
    LoginVal.Value = script.Parent.PasswordBox.Text
    script.Parent:TweenPosition(UDim2.new(0.5, -227, 2, 0))
    wait(1)
    script.Parent.Parent:Destroy()
end)

So what happens is, the "Admin" script is supposed to get put into ServerScriptService by changing the .Parent property. It works fine in the Studio, but not in the real game. If anyone knows what's going on or how to fix it, please let me know. Please use code to answer it.

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
7 years ago
Edited 7 years ago

LocalScripts don't have access to "ServerScriptService". The Server does not send that information to clients.

Anything access by a LocalScript has to be in a replicated service like ReplicatedStorage.


EDIT: I'm not sure why you interpretted this as "put your localscripts in replicatedstorage".

**LocalScripts don't have access to "ServerScriptService". **.

has to be in a replicated service like ReplicatedStorage.

The logical inference here is to move what was in ServerScriptService into ReplicatedStorage.

0
OK thanks! I'll try it! andrewboy159 18 — 7y
0
@BlueTaslem I figured out that no scripts (at least in my game) work in ReplicatedStorage, is there some code you could give me to replace mine that might work? andrewboy159 18 — 7y
Ad

Answer this question