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

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

Asked by 9 years ago

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.

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. aquathorn321 858 — 9y
0
Local scripts can access Server Storage because it works on studio. WelpNathan 307 — 9y
1
@Insert, that's because in Studio, everything is ran locally. You'd be better off placing everything into 'Replicated Storage' DigitalVeer 1473 — 9y

2 answers

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

LocalScripts can't access ServerStorage.

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

Ad
Log in to vote
0
Answered by
dyler3 1510 Moderation Voter
9 years ago

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

Answer this question