Screen Gui not becoming visible

I am making a flag script that displays a message when the flag is stolen it changes in-game and it says its visible, but I can’t see it. When I cut IP from the running game and pasted it when it was not running I could see it so I don’t know what’s going on.

sP = script.Parent

local flag = sP:WaitForChild(“Flag”)
local backupflag = flag:clone()
local flagHandle = flag:WaitForChild(“Handle”)
local backupflagHandle = flagHandle:clone()

local capturePoints = 25

local function updateStatus(status)
local newTextPrompt = game.StarterGui.ScoreboardGui.GameScoreFrame.EndPrompt
newTextPrompt.TextColor = sP.TeamColor.Value
if status == “Returned” then
newTextPrompt.Text = “Red teams flag has been returned!”
else
newTextPrompt.Text = “Red teams flag has been stolen!”
end
newTextPrompt.Parent = game.StarterGui.ScoreboardGui.GameScoreFrame
newTextPrompt.Visible = true
–wait(1)
–newTextPrompt.Visible = false
end

local function giveFlag(player)
–Update values
sP.FlagIsTaken.Value = true
sP.FlagTaker.Value = player.Character
updateStatus(“Stolen”)
–Put flag in player
flag.Parent = player.Character
flag.Handle.Anchored = false
–Attach flag to player
local newMotor = Instance.new(“Motor”)
newMotor.Name = “Flag”
newMotor.Parent = flag.Handle
newMotor.Part0 = player.Character.Torso
newMotor.Part1 = flag.Handle
newMotor.C1 = CFrame.new(1.25,0,-.75)*CFrame.fromEulerAnglesXYZ(0,0,-math.pi/9)

wait(1)

end

local function captureFlag(player)
–Update values
sP.FlagIsTaken.Value = false
sP.FlagTaker.Value = nil
end

–Goes to captureFlag or giveFlag
local function onTouch(part)
local humanoid = part.Parent:FindFirstChild(“Humanoid”)
if humanoid ~= nil and sP.FlagIsTaken.Value == false then
local getPlayers = game:GetService(“Players”)
local player = getPlayers:GetPlayerFromCharacter(part.Parent)

	if humanoid.Health > 0 then
		if player.TeamColor == sP.TeamColor and sP.FlagIsTaken.Value == false then
			captureFlag(player)
		else
			giveFlag(player)
		end
	end
end 

end

sP.Stand.Touched:connect(onTouch)
–mo.C1 = CFrame.new(1.25,0,-.75)*CFrame.fromEulerAnglesXYZ(0,0,-math.pi/9)

2 Likes

This is unreadable, please use

lua code blocks
2 Likes

You have to use player gui. In this line. The gui you see is player gui.
newTextPrompt.Parent = game.StarterGui.ScoreboardGui.GameScoreFrame

1 Like

So game.players.PlayerGui? How would I do all players this is not local script btw

A better way you can do it is add a script to the gui. Than you can add a touch and when it touches you add the visibility. Give me a momment and I will show you the script if you want.

1 Like

Yes please, that would be great!!

local players = game:GetService("Players").LocalPlayer
local Shop = workspace.Flag -- Rename it to the flag part

    Flag.Touched:Connect(function(Stole) -- Tests if the flag was touched
    if hit.Parent == player.Character then
    	script.Parent.ScreenGui.Frame.TextLabel.Text = "Flag Stolen" -- replace this line with what you want to happen
    	end
    end)

Put this script inside the screen gui you want to appear. This should work I think.

1 Like

What is it is a cloned prompt??

should I connect it should event?

Idk and also add a wait time and make the transperty 1. I used this to make a shop gui.

So create a local script put this code in it and then make it disabled and when prompt is created put it in it would that work?

Didn’t you want it a normal script?

Also put in the script you want I just made the inside as an example.

But you use local player in your code

Cant localplayer only be dont with a local script?

Oh, sorry. Just customize the script to your liking, I’m not %100 what you are doing. The script I gave you is an idea. So think about this. When a player touches the flag. It will say the text or what ever you want. Sorry that’s all I did.

I know this isn’t perfect, but my solution is using touch.

sP = script.Parent

local flag = sP:WaitForChild(“Flag”)
local backupflag = flag:clone()
local flagHandle = flag:WaitForChild(“Handle”)
local backupflagHandle = flagHandle:clone()

local capturePoints = 25

local function updateStatus(status)
local newTextPrompt = game.StarterGui.ScoreboardGui.GameScoreFrame.EndPrompt
newTextPrompt.TextColor = sP.TeamColor.Value
if status == “Returned” then
newTextPrompt.Text = “Red teams flag has been returned!”
else
newTextPrompt.Text = “Red teams flag has been stolen!”
end
newTextPrompt.Parent = game.StarterGui.ScoreboardGui.GameScoreFrame
newTextPrompt.Visible = true
–wait(1)
–newTextPrompt.Visible = false
end

local function giveFlag(player)
–Update values
sP.FlagIsTaken.Value = true
sP.FlagTaker.Value = player.Character
updateStatus(“Stolen”)
–Put flag in player
flag.Parent = player.Character
flag.Handle.Anchored = false
–Attach flag to player
local newMotor = Instance.new(“Motor”)
newMotor.Name = “Flag”
newMotor.Parent = flag.Handle
newMotor.Part0 = player.Character.Torso
newMotor.Part1 = flag.Handle
newMotor.C1 = CFrame.new(1.25,0,-.75)*CFrame.fromEulerAnglesXYZ(0,0,-math.pi/9)

wait(1)


end

local function captureFlag(player)
–Update values
sP.FlagIsTaken.Value = false
sP.FlagTaker.Value = nil
end

–Goes to captureFlag or giveFlag
local function onTouch(part)
local humanoid = part.Parent:FindFirstChild(“Humanoid”)
if humanoid ~= nil and sP.FlagIsTaken.Value == false then
local getPlayers = game:GetService(“Players”)
local player = getPlayers:GetPlayerFromCharacter(part.Parent)

if humanoid.Health > 0 then
	if player.TeamColor == sP.TeamColor and sP.FlagIsTaken.Value == false then
		captureFlag(player)
	else
		giveFlag(player)
	end
end

end


end

sP.Stand.Touched:connect(onTouch)
–mo.C1 = CFrame.new(1.25,0,-.75)*CFrame.fromEulerAnglesXYZ(0,0,-math.pi/9)

Umm… What did you even change???

I can’t read the codes, it’s messy.

1 Like