Part Not Being Found

In this script I have made, after the part is clicked, it is supposed to find a part int he workspace with the name ShishClicker…player.Name, but it just isn’t finding it, even though I can see it in the workspace. I have tried searching around the Dev Forum, but haven’t found a solution to my problem.
Here is the server script that controls this (located in the part inside of the workspace):

local ClickDetector = script.Parent.ClickDetector
local db = false
local Num = 1

local players = game.Players:GetPlayers()
for _, player in ipairs(players) do
	print(player.Name)
end

local function InvAll(obj)
	local shishMeshes = {
		obj.Vest.Shish1,
		obj.Vest.Shish2,
		obj.Vest.Shish3
	}

	for _, shishMesh in ipairs(shishMeshes) do
		if shishMesh then
			shishMesh.Transparency = 1
			wait(0)
		end
	end
end

ClickDetector.MouseClick:Connect(function(player)
	print("Shish Clicker Clicked")
	if not db then
		db = true

		local character = player.Character or player.CharacterAdded:Wait()
	
		print("Player Character:", character)
		
		local shishClicker = workspace:FindFirstChild("ShishClicker"..player.Name)
		print("Shish Clicker Name:", shishClicker and shishClicker.Name or "Not found")
		print("Player Name:", player.Name)

		if shishClicker then
			print("Shish Clicker Found")
			if character and character:FindFirstChild("Humanoid") and character:FindFirstChild("Vest") and shishClicker.Name == "ShishClicker"..player.Name then
				print("Clicker Name is Correct")
				local vest = character.Vest

				if Num == 1 then
					vest.Shish1.Transparency = 0
					Num = 2
				elseif Num == 2 then
					vest.Shish2.Transparency = 0
					vest.Shish1.Transparency = 1
					Num = 3
				elseif Num == 3 then
					vest.Shish3.Transparency = 0
					vest.Shish2.Transparency = 1
					Num = 4
				elseif Num == 4 then
					InvAll(character)
					Num = 1
				end
			end

			wait(0.1)
			db = false
		end
	end
end)

image

Is this it? "ShishClicker " ← space added
local shishClicker = workspace:FindFirstChild("ShishClicker "…player.Name)

I’m not sure what adding a space was supposed to do, but it didn’t work. The part name is ShishClickerjasper53682, not ShishClicker jasper53682.

Because I tested it and it found my name both ways. Figured yours had a space and that’s why it wasn’t finding it.

My output without the space:

  Shish Clicker Clicked
  Player Character: 2112Jay
  Shish Clicker Name: ShishClicker2112Jay
  Player Name: 2112Jay
  Shish Clicker Found

Are you sure you spelled ShishClicker the same… OR that it’s there at the moment of looking for it?

I figured out why it wasn’t working. Because the part is moved out of a part in the player to the workspace, it doesn’t register on the client, so it can’t find the part. I made the script above a local script, and it worked fine.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.