So I'm making a CTF game and here's what I have so far
script.Parent.RedFlag.Handle.Touched:connect(function()
for _, player in pairs(game.Workspace:GetChildren()) do
if player:FindFirstChild('RedFlag')then
print(player.Name..' has the RedFlag!')
end
end
end)
But the problem is that when I play the game in studio, the output says the parent that its in at the start, not when I touch it. So how do I make it so that when I touch it, the function triggers?

7 comments
Thanks! I'll try this out
I just tried it out and when I touch the flag, it's not saying that I have the flag in the output. Do you know why?
I also tried removing player.Name.. and it still doesn't print. PS: I made "Has the Red Flag!" to 'Has the Red Flag!'
edited it so now it should work
no need to change any of it
Ok
Thank you so much!