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

why do I get a error in game but not in studio it says that line 13 cant destroy a nil?

local plr = script.Parent.Parent.Parent.Parent.Parent
local Clicked = false

script.Parent.MouseButton1Click:Connect(function()
	local Twoplayers = math.random(1,2)
	local Threeplayers = math.random(1,3)
	local Fourplayers = math.random(1,4)
	local TableOfPlayers = game.Players:GetPlayers()
	script.Parent.Parent.Parent.Enabled = false
	if Clicked == false then
		Clicked = true
		for i = 0, 5 do
			local block = game.Workspace.Blocks:FindFirstChild(plr.Name)
			block:Destroy()
			Clicked = false
		end	
	end

Error is on line 13

2 answers

i think you have to put it as:

local block = game.Workspace.Blocks:FindFirstChild(tostring(plr.Name))

im not 100% sure it will work but yeah

1 comment

0

Alright will try

I found the answer it was a mistake with naming the cubes. Sorry for wasting anytime and thank you for anyone that helped me! and remember to always check over your code.

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