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
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.
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.
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.
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)