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

I'm having LocalScript problems with Values? [UNANSWERED]

Hello scripting helpers,

This is my 2nd question today and now I want to ask another question.

I've always had problems using LocalScripts. (This script is a LocalScript. I want it to stay a LocalScript too because I'm using game.Players.LocalPlayer instead of figuring out how to get to the player, I like to take the easy route.)

Here is the script I'm talking about.

local Frame = script.Parent.Question -- Fine
local Frame2 = script.Parent.Answer -- Fine
local Player = game.Players.LocalPlayer -- Fine

while true do -- Fine
	wait(1) -- Fine
	local InProgress = game.ServerStorage.InProgress -- ERROR
	local ContestantUp = game.ServerStorage.ContestantUp -- ERROR
	if InProgress.Value == true and ContestantUp.Value == Player.Name then -- Fine
			Frame:TweenPosition(UDim2.new(0.1, 0,0.6, 0), "Out", "Quad", 3, false) -- Fine
			Frame2:TweenPosition(UDim2.new(0.1, 0,0.8, 0), "Out", "Quad", 3, false) -- Fine
	else -- Fine
			Frame:TweenPosition(UDim2.new(0.1, 0,-0.6, 0), "Out", "Quad", 3, false) -- Fine
			Frame2:TweenPosition(UDim2.new(0.1, 0,-0.8, 0), "Out", "Quad", 3, false) -- Fine
	end -- Fine
end -- Fine

The script works fine in studio but not in game. It does not error in studio but it errors in game from looking at the Dev Console. The error is in the video. Here is what I mean:- https://www.youtube.com/watch?v=MseelbLQy2o

Thanks if you help! Nathan.

3 comments

0

just use PlayerAdded() in a normal script. I don't think local scripts can access Server Storage. If you want ti fix you problem the easy way, just move your Guis to Replicated Storage.

0

Local scripts can access Server Storage because it works on studio.

1

@Insert, that's because in Studio, everything is ran locally. You'd be better off placing everything into 'Replicated Storage'

2 answers

✓ Accepted answer

LocalScripts can't access ServerStorage.

Use ReplicatedStorage, for everything in it is replicated to the client.

Well, there's no way you're going to be able to do this because aquathorn was right. You need to use a server Script in order to access that service. When you want to test things inside of Studio, go to the "Test" tab, and click Start Server. Normal studio mode will sometimes allow things that a normal server wouldn't. Just try this inside of Normal Script for finding the player:

game.Players.PlayerAdded:connect(function(Plr)
	Player=Plr --This isn't really needed, but you can keep it if you like
	--Write your code here
end)

Ok, so if I didn't need that first part, someone please correct me, but I think this should work for you now. Try it in game if you want, and let me know if it works. Hope I helped :P

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