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

How Can I Detect What Team A Player Is On?

Asked by 4 years ago

I Am New To Scripting In Roblox And I Want To Detect What Team A Player Is On When A Model Is Clicked.

I Have Tried Many Methods But None Work. Here Is My Script:

local clickdetector = script.Parent
local bed = script.Parent.Parent

clickdetector.MouseClick:Connect(function(Clicker)
    if Clicker.Team == "Blue" then
        print("bed clicked by " .. Clicker.Name)
        bed:Destroy()
    end
end)

pls help

1 answer

Log in to vote
0
Answered by
A_Mp5 222 Moderation Voter
4 years ago

This should work, otherwise DM me on discord: A_Mp5#5847

-- local h = :FindFirstChild("Humanoid") (ignore this)
--local plyr = game.Players:FindFirstChild(Clicker.Parent.Name) (also ignore this)


    local clickdetector = script.Parent
    local bed = script.Parent.Parent

clickdetector.MouseClick:Connect(function(Clicker)
    local plyr = game.Players:FindFirstChild(Clicker.Name) -- if this doesn't work, make it: "Clicker.Parent.Name"
            if plyr.Team == "Blue" then
                    print("Bed clicked by " .. Clicker.Name..", on"..plyr.Team.."team!")
                    bed:Destroy()
          end
        end)
0
i would recommend using ``game:GetService("Players"):GetPlayerFromCharacter(Clicker)`` as the "plyr" (since display names are coming soon and it might tamper with the real username and fake username) CrazyCats84 154 — 4y
0
I fixed this problem it was just because i was switching teams with a localscript fgtv2222222222222222 14 — 4y
Ad

Answer this question