Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

the script still is on when I go to a different team, why? please tweak and explain.

i made a script so a othe script will only function when your on a specific team but the scrit does not stop even if im on a different team. I also want the script to enable again when I go back on the team, please help.

The localscript in starterplayerscripts:

local player = game.Players.LocalPlayer
if player.Team.TeamColor == game.Teams.Alive.TeamColor then
local StarterGui = player.PlayerGui
local UserInputService = game:GetService("UserInputService")
UserInputService.JumpRequest:Connect(function()
	StarterGui.ScreenGui.Frame.Visible = true
	wait(6)
	StarterGui.ScreenGui.Frame.Visible =  false
end)
end



local player = game.Players.LocalPlayer
if player.Team.TeamColor == game.Teams.Alive.TeamColor then
while true do
local StarterGui = player.PlayerGui
local UserInputService = game:GetService("UserInputService")
UserInputService.JumpRequest:Connect(function()
    StarterGui.ScreenGui.Frame.Visible = true
    wait(6)
    StarterGui.ScreenGui.Frame.Visible =  false
end)
end

1 answer

local player = game:GetService("Players").LocalPlayer
local UserInputService = game:GetService("UserInputService")
local StarterGui = player.PlayerGui
UserInputService.JumpRequest:Connect(function()
   	if player.Team.TeamColor == game.Teams.Alive.TeamColor then
    		StarterGui.ScreenGui.Frame.Visible = true
   		wait(6)
    		StarterGui.ScreenGui.Frame.Visible =  false
	end
end)

A loop is not needed - all you need to do is check to see if the player's team is Alive when they jump.

This discussion is preserved as it was. New answers, comments, and votes are closed.