Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

2 comments

0

OK thanks! I'll try it!

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?

This discussion is preserved as it was. New answers, comments, and votes are closed.