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

Script unable to access object?

Asked by 5 years ago
Edited 5 years ago

I am using Roblox Studio to test. The script is server-side (global).

The code I have is here:

function text(text, color, time_)
    workspace.TextValues.Texts = text
    workspace.TextValues.Color = color
    workspace.TextValues.Time = time_
    workspace.TextValues.Change:Fire()
end
function difnumtotext(num)
    if num == 0 then
        return "Easy"
    elseif num == 1 then
        return "Medium"
    elseif num == 2 then
        return "Hard"
    end
end

function difnumtocolor(num)
    if num == 0 then
        return Color3.fromRGB(0, 255, 0)
    elseif num == 1 then
        return Color3.fromRGB(255, 255, 0)
    elseif num == 2 then
        return Color3.fromRGB(255, 0, 0)
    end
end
--Some other code that does not relate goes here
function choosemap()
    local mapnumber = math.random(1,#game.ServerStorage:GetChildren())
    if mapnumber == 1 then
        local clone = startgame(game.ServerStorage.Map1)
        text(workspace.MapValues.Names.Value .. "[" .. difnumtotext(workspace.MapValues.Difficulty.Value) .. "] by " .. workspace.MapValues.Creator.Value, difnumtocolor(workspace.MapValues.Difficulty.Value), 5)
elseif mapnumber == 2 then
    local clone = startgame(game.ServerStorage.Map2)
    text(workspace.MapValues.Names.Value .. "[" .. difnumtotext(workspace.MapValues.Difficulty.Value) .. "] by " .. workspace.MapValues.Creator.Value, difnumtocolor(workspace.MapValues.Difficulty.Value), 5)
elseif mapnumber == 3 then
    local clone = startgame(game.ServerStorage.Map3)
    text(workspace.MapValues.Names.Value .. "[" .. difnumtotext(workspace.MapValues.Difficulty.Value) .. "] by " .. workspace.MapValues.Creator.Value, difnumtocolor(workspace.MapValues.Difficulty.Value), 5)
    end
end

I want to make it so the values in the folder (TextValues) change. Instead, I get the following error:

16:40:53.189 - Texts is not a valid member of Folder 16:40:53.190 - Stack Begin 16:40:53.190 - Script 'Workspace.GameScript', Line 10 - global text 16:40:53.191 - Script 'Workspace.GameScript', Line 53 - global choosemap 16:40:53.191 - Script 'Workspace.GameScript', Line 60 16:40:53.192 - Stack End

I know what it is saying but it doesn't make sense. I can see the folder and values existing right here: !workspace

Can someone please help me fix this? Thanks!

0
Which of these is line 60? SerpentineKing 3885 — 5y
0
Please use a code block. TheOnlySmarts 233 — 5y
0
Try using WaitForChild or FindFirstChild. MArzalAlBuchariZ 33 — 5y
0
Are you sure that there is a *folder* called TextValues? From what I'm seeing there is only one likely explanation, that TextValues doesn't really exist. birds3345 177 — 5y
0
Yes i am sure. If you didn't see i posted an image: https://imgur.com/GmCJfov bryancololee 0 — 5y

Answer this question