Hello there, I have already asked a question like this, but I still can't figure it out. As it says in the title, I'm having a bit of trouble with this script.
local a = math.random(1, game.Players.NumPlayers) plyrs = game.Players:GetChildren() for i = 1, #plyrs do rand = plyrs[a] end character = rand.Character print("Player chosen: "..rand.Name) wait(1) character.Torso.Touched:connect(function(hit) local touched = game.Players:GetPlayerFromCharacter(hit.Parent) if touched then print(rand.Name.." touched ".. touched.Name.."!") end end)
I am just analysing this script and I do not claim this script is mine. I'm just trying to understand it, but whenever I start a 2 player server, the print(rand.Name.."touched"..touched.Name.."!") does not show in the output. Could anyone tell me what is wrong with the script? Oh and also, this is not the whole script, so sorry if I missed anything in it