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

How can I get the team of the player who triggered the ProximityPrompt ?

Asked by 2 years ago
Edited 2 years ago

Hi ! I ve a problem with my script on Roblox... I want to get the team of the player who triggered the proximity prompt of the door, but my script dont work ?? Does someone know a solution for tuhis problem ? Thanks in advance !

detector1.Triggered:Connect(function(player)
    if player.Team == "Tau'ri" then
        if isInAction == false then
            if door.Position == Vector3.new(10418, 6.4, -431.5) then
                close()
            else
                open()
            end
        end
    end
end)

(And excuse me for my English, Im french !)

4 answers

Log in to vote
0
Answered by 2 years ago
if player.Team == game.Teams["Tau'ri"] then
0
Thanks bro ! It works ! KingAquitain 35 — 2y
Ad
Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
2 years ago
Edited 2 years ago

You could use

local function onPromptHoldEnded(promptObject, player)
    -- script
end

ProximityPromptService.PromptButtonHoldEnded:Connect(onPromptHoldEnded)
0
That dont work ? KingAquitain 35 — 2y
Log in to vote
0
Answered by 2 years ago
Edited 2 years ago
local detector1 = script.Parent.Parent.Model1.Detector.PromptAttachment.ProximityPrompt
local detector2 = script.Parent.Parent.Model2.Detector.PromptAttachment.ProximityPrompt
local door = script.Parent
local partDoor = script.Parent.Union
local isInAction = false
ProximityPromptService = game:GetService("ProximityPromptService")

local function open()
    door.Position = Vector3.new(10430, 6.4, -431.5)
    partDoor.Position = Vector3.new(10430, 6.4, -431.5)
    if isInAction == false then
        while door.Position ~= Vector3.new(10418, 6.4, -431.5) do
            isInAction = true
            door.Position = door.Position - Vector3.new(0.0625 , 0 , 0)
            partDoor.Position = partDoor.Position - Vector3.new(0.0625 , 0 , 0)
            wait(0.001)
        end
    end
    isInAction = false
    detector1.ActionText = "Close"
    detector2.ActionText = "Close"
end

local function close()
    door.Position = Vector3.new(10418, 6.4, -431.5)
    partDoor.Position = Vector3.new(10418, 6.4, -431.5)
    if isInAction == false then 
        while door.Position ~= Vector3.new(10430, 6.4, -431.5) do
            isInAction = true
            door.Position = door.Position + Vector3.new(0.0625 , 0 , 0)
            partDoor.Position = partDoor.Position + Vector3.new(0.0625, 0 , 0)
            wait(0.001)
        end
    end
    isInAction = false
    detector1.ActionText = "Open"
    detector2.ActionText = "Open"
end

local function onPromptHoldEnded(promptObject, player)
    if player.Team == "Tau'ri" then
        if isInAction == false then
            if door.Position == Vector3.new(10418, 6.4, -431.5) then
                close()
            else
                open()
            end
        end
    end
end

But the script of the question works when I don't want to add the condition of the player's team

Log in to vote
0
Answered by 2 years ago
if player.TeamColor == game.Teams["Tau'ri"].TeamColor then

Answer this question