I made this script and it looks perfect, but when I touch the king (you will understand what I mean later) NOTHING HAPPENS! And I mean nothing, not an error, nothing crashes, nothing! Here is my code

local function onTouch(hit)
	if hit.Parent.Humanoid ~= nil then
		print('one')
		if hit.Parent:FindFirstChild("Humanoid") then
			print('two')
        	local plr = workspace[hit.Parent.Name] --Access character from workspace.
        	local play = game.Players:GetPlayerFromCharacter(plr) --Access (plr)
			print(play.Team)
        	if play.Team == "Offence" then
				print('three')
				print (hit.Parent)
				KingTouch = 9
				print(KingTouch)
				
			end			
        end
    end	
end





for i = 300,0,-1 do
	if KingTouch == 1 then
		game.Workspace.mapStorage.map.King.Torso.Touched:connect(onTouch)
		status.Value = 'you have '..i..' seconds left'
		wait(1)
	end
	
end

after I touch the king it does however print out 'one', 'two', and 'Offence' but no 'three'

PLEASE HELP!

2 comments

0

if play.Team.Name == 'Offence'?

0

if play.Team.Name == offence. You don't have a set variable for offence. Not that I see, anyways. That's probably where you're going wrong.