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

Serverscript wont detect NumberValue in ServerStorage?

Asked by 4 years ago

So inside a birck is this script:

local AI = game.ServerStorage.FredAI.Value
if AI == 1
then

    print("Test")
    script.Parent.Transparency = 1
end

However, "Test" is never printed and the block never changed its transprency.

I know that the value changes, as I have a script to print the current value some time after the value is changed, and it says 1, also I hit run and watched the value chaged.

Any solutions?

0
You're going to need a loop if the AI value is changed after the game starts josestankor 39 — 4y
0
I also recommend you to move the value from ServerStorage to ReplicatedStorage josestankor 39 — 4y
0
wow.. coincidence? Hydrogyn 155 — 4y

1 answer

Log in to vote
2
Answered by
Hydrogyn 155
4 years ago
Edited 4 years ago

hello, Adenandpuppy. I've brought up a couple of solutions.

SOLUTION 1

Solution 1 is pretty simple you create a while true do loop to constantly check the value.

local AI = game.ServerStorage.FredAI

while true do
    wait() 
    if AI.Value == 1 then
        script.Parent.Transparency = 1
    end
end

SOLUTION 2

If the script you are using is an localscript then you simply cannot access serverstorage. Instead use replicatedstorage as both normal scripts and localscripts can access the contents of it.

--

I hope this helps!

// hydrogyn

Ad

Answer this question