Part.Touched Not firing, or outputting errors

I am trying to make a map voting system, and all is well except for the fact that the function Part.Touched will NOT work, I’ve tried checking the CanTouch and CanQuery values and theyre on, and so i thought it was a studio issue, but it didnt even print when I went In Game. I don’t believe this is a plugin causing this, and I’ve even asked a friend for some advice and they’re just as confused as me.

The function:

lobby:WaitForChild("Vote1").Touched:Connect(function(toucher)
	
	print("touched")
	
end)

The layout:
image

I’ve even checked to see if maybe there was something In the game there wasn’t supposed to be, like maybe a loose script, but no. I have no idea how to fix this, unless im doing something wrong on my end.

If it helps at all, here is the whole script (remember its not finished quite yet either):

local timer = 45
local timerActive = true
local intermissionTime = 45
local intermission = false
local rs = game:GetService("ReplicatedStorage")
local lobby = workspace.Lobby
local chosenmap = nil
local playerVotes = {}
local Maps = {
	
	["Baseplate"] = {
		["MatchTime"] = 180,
		["Modes"] = {
			[1] = "ffa",
			[2] = "tdm"
		},
		["MapImage"] = "rbxassetid://18479648105"
	},
	["Happy Home"] = {
		["MatchTime"] = 300,
		["Modes"] = {
			[1] = "ffa",
			[2] = "tdm"
		},
		["MapImage"] = "rbxassetid://15554666501"
	}
}

local MapNames = {}
local ChosenMap1 = nil
local Map1Votes = {}
local ChosenMap2 = nil
local Map2Votes = {}
local ChosenMap3 = nil
local Map3Votes = {}

for key,_ in pairs(Maps) do
	table.insert(MapNames, key)
end
print(MapNames)

local function StartMapVoting()
	ChosenMap1 = MapNames[math.random(1, #MapNames)]
	ChosenMap2 = MapNames[math.random(1, #MapNames)]
	ChosenMap3 = MapNames[math.random(1, #MapNames)]
	print(ChosenMap1)
	print(ChosenMap2)
	print(ChosenMap3)
	
	lobby.Screen1.SurfaceGui.MapName.Text = ChosenMap1
	lobby.Screen2.SurfaceGui.MapName.Text = ChosenMap2
	lobby.Screen3.SurfaceGui.MapName.Text = ChosenMap3
	lobby.Screen1.SurfaceGui.MapImage.Image = Maps[ChosenMap1]["MapImage"]
	lobby.Screen2.SurfaceGui.MapImage.Image = Maps[ChosenMap2]["MapImage"]
	lobby.Screen3.SurfaceGui.MapImage.Image = Maps[ChosenMap3]["MapImage"]
	
end

while wait(1) do
	if timer >= 1 then
		if timerActive == true then
			timer -= 1
			print(timer)
			if timer == 0 then
				if intermission == true then
					print("match start")
					chosenmap = nil
					intermission = false
					timer = Maps[chosenmap]["MatchTime"]
				else
					print("match end")
					intermission = true
					wait(5)
					StartMapVoting()
					for i, v in pairs(game.Players:GetChildren()) do
						v.Character:PivotTo(lobby.LobbyTP.CFrame)
						v.Team = game.Teams.Unassigned
					end
					timer = intermissionTime
				end
			end
		end
	end
end

lobby:WaitForChild("Vote1").Touched:Connect(function(toucher)
	
	print("touched")
	
end)

while loops are blocking. Code after them won’t execute until they break. You can get around this by using a coroutine.

task.spawn(function()
    while true do
        wait(1)
        print("a")
    end
end)

print("b")

prints b then repeatedly prints a

1 Like

Shouldn’t utilize task.wait instead of wait?

Typo, I meant you not utilize, typing on my phone.


yes

1 Like

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