Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this part of my code not working? (It says I must be more specific so I am writing this)

Asked by
TNTeon -1
6 years ago

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!

0
`if play.Team.Name == 'Offence'`? TheeDeathCaster 2368 — 6y
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. ZenTGE 4 — 6y

Answer this question