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

Why won't this function work? It seems alright...

I was making my cafe's point system until I stumbled across an error. (No error outputted) The code block seems fine, however there is still an error. Can anyone help me solve this problem? Code below:

			for _,player in pairs(Players:GetChildren()) do
				local function lookForTools()-- THE FOLLOWING CODE BLOCK IS THE ERROR
					wait()
					local target = player.Backpack:GetChildren():IsA("Tool").CreatorString or player.Character:GetChildren():IsA("Tool").CreatorString
					if target.Value == string.sub(tostring(player.Name),1,string.len(player.Name)) and target.Parent.Parent == not string.sub(tostring(player.Name),1,string.len(player.Name)) or target.Parent.Parent.Parent == not string.sub(tostring(player.Name),1,string.len(player.Name)) then
						print("caught red handed JKFSADAS")
					end
				end
			end

1 answer

i hope i could fix your problem by making the function code outside here is how i do it (btw you didn't called your function so that is probably why it doesn't work)

local function lookForTools()
        wait()
        local target = player.Backpack:GetChildren():IsA("Tool").CreatorString or player.Character:GetChildren():IsA("Tool").CreatorString
        if target.Value == string.sub(tostring(player.Name),1,string.len(player.Name)) and target.Parent.Parent == not string.sub(tostring(player.Name),1,string.len(player.Name)) or target.Parent.Parent.Parent == not string.sub(tostring(player.Name),1,string.len(player.Name)) then
        print("caught red handed JKFSADAS")
        end
end 
for _,player in pairs(Players:GetChildren()) do
    	lookForTools()
end

I really hope that would help you ! ^^

7 comments

0

I wish it would work since I wouldn't want to bother you, but I'm sorry, it still doesn't work, yet again; No outputted error. :c

0

Hmm that is weird, can you add a wait so that when you are fully loaded then the script will run

0

Still won't work. If you would like to you can add me, user: ISkyLordDoge.

0

Where is this script located?

0

Server Script Service.

0

Can you insert some print statements in LookForTools to see where it fails a conditional or hangs

0

Could you ellaborate, please? ^~^

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