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

Script wont work for some reason. Any ideas why?

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?

7 comments

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,

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)

0

Read line 2 of your script. Is that FindFirstChild?

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)

0

Well then that means that there is no Humanoid object in workspace.

0

That is strange since i can located the Humanoid object in workspace myself

0

You sure it's a direct child of workspace and not just a descendant?

1 answer

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)

1 comment

0

It will glitch if there's players in the game, unless you rename their humanoids somewhere or something.

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