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

Script wont work for some reason. Any ideas why?

Asked by 9 years ago
Workspace.Startevent.Changed:connect(function()
    local selk = workspace:IsA('Humanoid')
    selk.Parent.Seeker.Value = true
    repeat
        wait()
    until sek == 1
    workspace.GameInProgress.Value = true
    t = 20  --game time
    repeat
        wait(1)
        t = t-1
        print(t)
        if gameend.Value then
            t = 0
        end
    until t == 0
    wait(0.1)
    t = 20
    gameend.Value = true
    wait(0.1)
    gameend.Value = false
end)

the script is trying to locate a BoolValue inside a player model

it would be like this:

local BoolValue = Humanoid.Parent.Seeker

Dont get me wrong, it locates the BoolValue but it puts out an error:

Workspace.GameStart:47: attempt to index local 'selk' (a boolean value)

Any ideas?

0
What are you trying to do? workspace obviously is not a humanoid. And IsA() returns a bool value, so it doesn't have a parent, Perci1 4988 — 9y
0
Trying to do" selk = workspace:FindFirstChild("Humanoid") "and then with " selk.Parent.Seeker.Value = true "   but it returns a error: Workspace.GameStart:47: attempt to index local 'selk' (a nil value) mariko229 0 — 9y
0
Read line 2 of your script. Is that FindFirstChild? Perci1 4988 — 9y
0
no, but i tried it with FindFirstChild and it puts out an error: Workspace.GameStart:47: attempt to index local 'selk' (a nil value) mariko229 0 — 9y
View all comments (3 more)
0
Well then that means that there is no Humanoid object in workspace. Perci1 4988 — 9y
0
That is strange since i can located the Humanoid object in workspace myself mariko229 0 — 9y
0
You sure it's a direct child of workspace and not just a descendant? Perci1 4988 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Found the solution myself:

Workspace.Startevent.Changed:connect(function()
    local selk = Workspace:FindFirstChild("Humanoid", true)
    print(selk)
    selk.Parent.Seeker.Value = true
    repeat
        wait()
    until sek == 1
    workspace.GameInProgress.Value = true
    t = 20  --game time
    repeat
        wait(1)
        t = t-1
        print(t)
        if gameend.Value then
            t = 0
        end
    until t == 0
    wait(0.1)
    t = 20
    gameend.Value = true
    wait(0.1)
    gameend.Value = false
end)

The Humanoid was inside a model so you have to use the second argument in FindFirstChild("Humanoid", true)

0
It will glitch if there's players in the game, unless you rename their humanoids somewhere or something. Perci1 4988 — 9y
Ad

Answer this question