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)