generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Why do GUIs not usually work in Play Solo?

Previous Thread :: Next Thread 
pearman is not online. pearman
Joined: 05 Jun 2009
Total Posts: 1681
01 Aug 2013 04:07 PM
I know this should be in Scripting Helpers, but I'm tired of waiting 3 days with no helpful responses.
Report Abuse
BlueTaslem is not online. BlueTaslem
Joined: 11 May 2008
Total Posts: 11060
01 Aug 2013 04:10 PM
They do? What?
Report Abuse
BaileyUnivix is not online. BaileyUnivix
Joined: 30 Jul 2013
Total Posts: 121
01 Aug 2013 04:11 PM
Explain what you mean when you say that it does not work in Solo?

They have always worked for me in Solo, unless your GUI's are not located correct or not visible?
Report Abuse
pearman is not online. pearman
Joined: 05 Jun 2009
Total Posts: 1681
01 Aug 2013 04:12 PM
Sorry I was being derpy, they work in Play Solo for me, but not in Public mode.
Report Abuse
pearman is not online. pearman
Joined: 05 Jun 2009
Total Posts: 1681
01 Aug 2013 04:13 PM
For example, this script I made :

--[[ Load our sounds in ]]--

local transitionSound = Instance.new("Sound", game.Workspace) -- Change on_touch to your brick name
game.Workspace:WaitForChild("Sound") -- Wait until this sound is created
transitionSound.Volume = .25
transitionSound.Pitch = 3
transitionSound.Name = "transitionSound"
transitionSound.SoundId = "http://www.roblox.com/Asset/?ID=11949128"

local ding = Instance.new("Sound", game.Workspace) -- Change on_touch to your brick name
game.Workspace:WaitForChild("Sound")
ding.Volume = 2
ding.Pitch = 3
ding.Name = "ding"
ding.SoundId = "http://www.roblox.com/asset/?id=19344667"

--[[ Pre-load the images and the sounds for the GUI ]]--

Game:GetService("ContentProvider"):Preload("http://www.roblox.com/Asset/?ID=11949128")
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=19344667")
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=124402522")
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=124402304")

--[[ Initialize our variables ]]--
local playerName = ""
local enableClickHandler = true
local TIME = 0.1 -- Change this to any delay you want
local debounce = false

function ShiftColors( TextButton, maxLoop )
local o = 0

for o = 0, maxLoop do
TextButton.TextColor3 = Color3.new(1,0,0)
wait(TIME)
TextButton.TextColor3 = Color3.new(1,1,1)
wait(TIME)
end
end

function UpdatePercent(image2, percent, percentText)
if script.IsPlayerAlive.Value then
local value = ((310/100) * percent)

image2:TweenSize(UDim2.new(0, value, 0, 25), "Out", "Linear", TIME)
percentText.Text = percent.."%"
else
return
end
end

function CreateGUI(playerName, player, character)

--[[ Create the GUI ]]--

local MyGUI = Instance.new("ScreenGui", player.PlayerGui)
player.PlayerGui:WaitForChild("ScreenGui") -- Make sure the ScreenGui has loaded
MyGUI.Name = "touchedGUI"

--[[ Create our frame ]]--

local MyFrame = Instance.new("Frame", MyGUI)
player.PlayerGui.touchedGUI:WaitForChild("Frame") -- Wait for the frame to load
MyFrame.Size = UDim2.new(0, 600, 0, 250)
MyFrame.Position = UDim2.new(.5, -300, .5, -125)
MyFrame.Style = "RobloxRound"
MyFrame.Active = true
MyFrame.Draggable = true
MyFrame.BackgroundColor3 = Color3.new(0,0,0)

--[[ Create our TextButton ]]--

local MyTextButton = Instance.new("TextButton", MyFrame)
player.PlayerGui.touchedGUI.Frame:WaitForChild("TextButton") -- Wait for the text button to load
MyTextButton.Size = UDim2.new(0, 200, 0, 75)
MyTextButton.Position = UDim2.new(.33, .10, .1, .1)
MyTextButton.Font = "ArialBold"
MyTextButton.FontSize = "Size36"
MyTextButton.TextScaled = true
MyTextButton.TextWrapped = true
MyTextButton.TextColor3 = Color3.new(1,1,1)
MyTextButton.BackgroundTransparency = 1
MyTextButton.Text = "Capture"

--[[ Create our two ImageLabels ]]--

local MyImageLabel1 = Instance.new("ImageLabel", MyFrame)
player.PlayerGui.touchedGUI.Frame:WaitForChild("ImageLabel") -- Wait for the image label to load
MyImageLabel1.Name = "ImageLabel1"
MyImageLabel1.Image = "http://www.roblox.com/asset/?id=124402522"
MyImageLabel1.BackgroundTransparency = 1
MyImageLabel1.Size = UDim2.new(0, 400, 0, 300)
MyImageLabel1.Position = UDim2.new(.16, 0, .27, 0)
MyImageLabel1.ZIndex = 1

local MyImageLabel2 = Instance.new("ImageLabel", MyFrame)
player.PlayerGui.touchedGUI.Frame:WaitForChild("ImageLabel") -- Wait for the image label to load
MyImageLabel2.Name = "ImageLabel2"
MyImageLabel2.BackgroundColor3 = Color3.new(1,0,0)
MyImageLabel2.BackgroundTransparency = 0
MyImageLabel2.Size = UDim2.new(0, 0, 0, 0)
MyImageLabel2.Position = UDim2.new(.238, 0, .754, 0)
MyImageLabel2.ZIndex = 2

--[[ Create the TextLabel showing the precent captured ]]--

local MyTextLabel = Instance.new("TextLabel", MyFrame)
player.PlayerGui.touchedGUI.Frame:WaitForChild("TextLabel") -- Wait for the text label to load
MyTextLabel.Size = UDim2.new(0, 400, 0, 300)
MyTextLabel.Position = UDim2.new(.16, 0, -.1, 0)
MyTextLabel.Font = "ArialBold"
MyTextLabel.FontSize = "Size18"
MyTextLabel.TextScaled = true
MyTextLabel.TextWrapped = true
MyTextLabel.TextColor3 = Color3.new(1,0,0)
MyTextLabel.BackgroundTransparency = 1
MyTextLabel.Text = "0%"

local percentage = 0

script.IsPlayerAlive.Value = true -- Keeps track of player's life

character.Humanoid.Died:connect(function()
script.IsPlayerAlive.Value = false
end)

MyTextButton.MouseButton1Down:connect(function()
if script.IsPlayerAlive.Value then

ShiftColors(MyTextButton, 3) -- Change colors 3 times on startup

MyTextButton.Text = "Capturing.."

while percentage < 100 do
if script.IsPlayerAlive.Value then

transitionSound:Play() -- Play a sound to signify the next iteration
percentage = percentage + 1 -- increment percentage

UpdatePercent(MyImageLabel2, percentage, MyTextLabel) -- update labels
ShiftColors(MyTextButton, 1) -- change colors
else
script.CanExit.Value = true
break
end
end

if script.IsPlayerAlive.Value then
MyTextButton.Text = "Captured!"
MyTextButton.TextColor3 = Color3.new(1,0,0) -- change to red in the end
ding:Play() -- Play a sound to signify we're done

if player.TeamColor == BrickColor.Red() then
script.Parent.Parent.Name = "Red Raiders"
script.Parent.Parent.Flag.BrickColor = BrickColor.Red()
script.Parent.Parent.Head.PointLight.Color = Color3.new(1,0,0)
else if player.TeamColor == BrickColor.new("Bright green") then
script.Parent.Parent.Name = "Green Clan"
script.Parent.Parent.Flag.BrickColor = BrickColor.Green()
script.Parent.Parent.Head.PointLight.Color = Color3.new(0,1,0)
else
script.Parent.Parent.Name = "Blue Clan"
script.Parent.Parent.Flag.BrickColor = BrickColor.Blue()
script.Parent.Parent.Head.PointLight.Color = Color3.new(0,0,1)
end
end

script.CanExit.Value = true -- Signal that we can exit
end
end
end)

while script.CanExit.Value == false do wait(3) end

script.CanExit.Value = false

player.PlayerGui.touchedGUI.Frame.TextButton:Remove()
player.PlayerGui.touchedGUI.Frame.ImageLabel1:Remove()
player.PlayerGui.touchedGUI.Frame.ImageLabel2:Remove()
player.PlayerGui.touchedGUI.Frame.TextLabel:Remove()
player.PlayerGui.touchedGUI.Frame:Remove()
player.PlayerGui.touchedGUI:Remove()

end

script.Parent.Touched:connect(function(part) -- Activate on touch

if debounce then return end

debounce = true

local character = part.Parent
local player = Game.Players:GetPlayerFromCharacter(character)

if player and character then

player:WaitForChild("IsGUIactive")

if player.IsGUIactive.Value == false then

player.IsGUIactive.Value = true

CreateGUI(player.Name, player, character)

player.IsGUIactive.Value = false
end
end

debounce = false

end)


Does absolutely nothing in public mode, but is perfect in Play Solo.
Report Abuse
bohdan77 is not online. bohdan77
Joined: 10 Aug 2008
Total Posts: 7944
01 Aug 2013 04:52 PM
Is that in a localscript,etc
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
01 Aug 2013 05:24 PM
in play solo, everything is local even normal scripts
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
01 Aug 2013 05:32 PM
I am somewhat disgusted when I see both .Touched events and GuiObject events being handled in the same script...

Sorry, but unless you're dealing with local parts, using the .Touched event in a LocalScript is not what I'd recommend to do.

Well, you can make an output-thingy for your game and make the script send output on the 1st line ect. also, REMS. Dunno, I don't feel like going through the script now :I

- As, fear the Quincy, I say! FEAR HIM! Quote: 'Tell him to fear the Quincy', - A Quincy.
Report Abuse
pearman is not online. pearman
Joined: 05 Jun 2009
Total Posts: 1681
02 Aug 2013 09:25 AM
It's not in a localscript, it's in a regular script. I didn't know how to separate the code into smaller scripts so I just handled it all in one big piece of code. Should it be a localscript to work in public mode?
Report Abuse
pearman is not online. pearman
Joined: 05 Jun 2009
Total Posts: 1681
02 Aug 2013 09:25 AM
Oh, and this script is inside of the brick( it's basically a capture the flag GUI )
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
02 Aug 2013 10:00 AM
Hm.

I do not suggest handling GuiObject events in server-sided scripts.


Well, as I said before, try make an output-thing for online testing. You can use ypcall to catch errors from (Local)Scripts.

- As, local succ, errM = ypcall(function() blah, full script end) while wait(1) do if not succ ...blah.
Report Abuse
pearman is not online. pearman
Joined: 05 Jun 2009
Total Posts: 1681
02 Aug 2013 12:17 PM
^ Still no. I tried using a different method of handling the OnTouched event in a regular script inside of the brick. Then I used that script to clone a localscript with the information needed to run the GUI in the player's PlayerGui and locally created the GUI in there. I created another script to create a hint instance and update it with text from a string value in Workpsace every 5 seconds. Then I got the return value from ypcall and converted it to a string using tostring(). I then removed the GUI that was created from the localscript and removed the localscript after it was done in the regular script in the brick. This worked out perfectly in Play Solo, and the hint message that displayed was "true". Of course, it didn't work in public mode. I still have no idea why.

Script inside of the brick :

local debounce = false

script.Parent.Touched:connect(function(part) -- Activate on touch

if debounce then return end

debounce = true

local character = part.Parent
local player = Game.Players:GetPlayerFromCharacter(character)

if player and character then

player:WaitForChild("IsGUIactive")

if player.IsGUIactive.Value == false then

player.IsGUIactive.Value = true

local localScriptCopy = script.Parent.LocalScript:Clone()
localScriptCopy.Model.Value = script.Parent.Parent.Name
localScriptCopy.Parent = player.PlayerGui
localScriptCopy.Disabled = false

while player.IsGUIactive.Value do wait(3) end

localScriptCopy:Remove()
end
end

debounce = false

end)

LocalScript inside the player's PlayerGui :

--[[ Initialize the sounds ]]--

local transitionSound = Instance.new("Sound", game.Workspace) -- Change on_touch to your brick name
game.Workspace:WaitForChild("Sound") -- Wait until this sound is created
transitionSound.Volume = .25
transitionSound.Pitch = 3
transitionSound.Name = "transitionSound"
transitionSound.SoundId = "http://www.roblox.com/Asset/?ID=11949128"

local ding = Instance.new("Sound", game.Workspace) -- Change on_touch to your brick name
game.Workspace:WaitForChild("Sound")
ding.Volume = 2
ding.Pitch = 3
ding.Name = "ding"
ding.SoundId = "http://www.roblox.com/asset/?id=19344667"

--[[ Initialize our variables ]]--

local enableClickHandler = true
local TIME = 0.1 -- Change this to any delay you want

function ShiftColors( TextButton, maxLoop )
local o = 0

for o = 0, maxLoop do
TextButton.TextColor3 = Color3.new(1,0,0)
wait(TIME)
TextButton.TextColor3 = Color3.new(1,1,1)
wait(TIME)
end
end

function UpdatePercent(image2, percent, percentText)
if script.IsPlayerAlive.Value then
local value = ((310/100) * percent)

image2:TweenSize(UDim2.new(0, value, 0, 25), "Out", "Linear", TIME)
percentText.Text = percent.."%"
else
return
end
end

function CreateGUI(player, character)

--[[ Create the GUI ]]--

local MyGUI = Instance.new("ScreenGui", player.PlayerGui)
player.PlayerGui:WaitForChild("ScreenGui") -- Make sure the ScreenGui has loaded
MyGUI.Name = "touchedGUI"

--[[ Create our frame ]]--

local MyFrame = Instance.new("Frame", MyGUI)
player.PlayerGui.touchedGUI:WaitForChild("Frame") -- Wait for the frame to load
MyFrame.Size = UDim2.new(0, 600, 0, 250)
MyFrame.Position = UDim2.new(.5, -300, .5, -125)
MyFrame.Style = "RobloxRound"
MyFrame.Active = true
MyFrame.Draggable = true
MyFrame.BackgroundColor3 = Color3.new(0,0,0)

--[[ Create our TextButton ]]--

local MyTextButton = Instance.new("TextButton", MyFrame)
player.PlayerGui.touchedGUI.Frame:WaitForChild("TextButton") -- Wait for the text button to load
MyTextButton.Size = UDim2.new(0, 200, 0, 75)
MyTextButton.Position = UDim2.new(.33, .10, .1, .1)
MyTextButton.Font = "ArialBold"
MyTextButton.FontSize = "Size36"
MyTextButton.TextScaled = true
MyTextButton.TextWrapped = true
MyTextButton.TextColor3 = Color3.new(1,1,1)
MyTextButton.BackgroundTransparency = 1
MyTextButton.Text = "Capture"

--[[ Create our two ImageLabels ]]--

local MyImageLabel1 = Instance.new("ImageLabel", MyFrame)
player.PlayerGui.touchedGUI.Frame:WaitForChild("ImageLabel") -- Wait for the image label to load
MyImageLabel1.Name = "ImageLabel1"
MyImageLabel1.Image = "http://www.roblox.com/asset/?id=124402522"
MyImageLabel1.BackgroundTransparency = 1
MyImageLabel1.Size = UDim2.new(0, 400, 0, 300)
MyImageLabel1.Position = UDim2.new(.16, 0, .27, 0)
MyImageLabel1.ZIndex = 1

local MyImageLabel2 = Instance.new("ImageLabel", MyFrame)
player.PlayerGui.touchedGUI.Frame:WaitForChild("ImageLabel") -- Wait for the image label to load
MyImageLabel2.Name = "ImageLabel2"
MyImageLabel2.BackgroundColor3 = Color3.new(1,0,0)
MyImageLabel2.BackgroundTransparency = 0
MyImageLabel2.Size = UDim2.new(0, 0, 0, 0)
MyImageLabel2.Position = UDim2.new(.238, 0, .754, 0)
MyImageLabel2.ZIndex = 2

--[[ Create the TextLabel showing the precent captured ]]--

local MyTextLabel = Instance.new("TextLabel", MyFrame)
player.PlayerGui.touchedGUI.Frame:WaitForChild("TextLabel") -- Wait for the text label to load
MyTextLabel.Size = UDim2.new(0, 400, 0, 300)
MyTextLabel.Position = UDim2.new(.16, 0, -.1, 0)
MyTextLabel.Font = "ArialBold"
MyTextLabel.FontSize = "Size18"
MyTextLabel.TextScaled = true
MyTextLabel.TextWrapped = true
MyTextLabel.TextColor3 = Color3.new(1,0,0)
MyTextLabel.BackgroundTransparency = 1
MyTextLabel.Text = "0%"

local percentage = 0

script.IsPlayerAlive.Value = true -- Keeps track of player's life

character.Humanoid.Died:connect(function()
script.IsPlayerAlive.Value = false
end)

MyTextButton.MouseButton1Down:connect(function()
if script.IsPlayerAlive.Value then

ShiftColors(MyTextButton, 3) -- Change colors 3 times on startup

MyTextButton.Text = "Capturing.."

while percentage < 100 do
if script.IsPlayerAlive.Value then

transitionSound:Play() -- Play a sound to signify the next iteration
percentage = percentage + 1 -- increment percentage

UpdatePercent(MyImageLabel2, percentage, MyTextLabel) -- update labels
ShiftColors(MyTextButton, 1) -- change colors
else
script.CanExit.Value = true
break
end
end

if script.IsPlayerAlive.Value then
MyTextButton.Text = "Captured!"
MyTextButton.TextColor3 = Color3.new(1,0,0) -- change to red in the end
ding:Play() -- Play a sound to signify we're done

local model = game.Workspace:FindFirstChild(script.Model.Value)

if model then
if player.TeamColor == BrickColor.Red() then
model.Flag.BrickColor = BrickColor.Red()
model.Head.PointLight.Color = Color3.new(1,0,0)
else if player.TeamColor == BrickColor.new("Bright green") then
model.Flag.BrickColor = BrickColor.Green()
model.Head.PointLight.Color = Color3.new(0,1,0)
else
model.Flag.BrickColor = BrickColor.Blue()
model.Head.PointLight.Color = Color3.new(0,0,1)
end
end
end

script.CanExit.Value = true -- Signal that we can exit
end
end
end)

while script.CanExit.Value == false do wait(3) end

script.CanExit.Value = false
player.IsGUIactive.Value = false

player.PlayerGui.touchedGUI.Frame.TextButton:Remove()
player.PlayerGui.touchedGUI.Frame.ImageLabel1:Remove()
player.PlayerGui.touchedGUI.Frame.ImageLabel2:Remove()
player.PlayerGui.touchedGUI.Frame.TextLabel:Remove()
player.PlayerGui.touchedGUI.Frame:Remove()
player.PlayerGui.touchedGUI:Remove()
end

function StartScript()
game.Workspace.message.Value = tostring(ypcall(CreateGUI, game.Players.LocalPlayer, game.Players.LocalPlayer.Character))
end

StartScript()


Also, the hint never gets updated in public mode.
Report Abuse
IeCat is not online. IeCat
Joined: 31 Jul 2013
Total Posts: 42
02 Aug 2013 12:19 PM
@OP I suggest adding a wait() to the beginning of the script. It should solve your problems.
~> Have a nice day.
Report Abuse
pearman is not online. pearman
Joined: 05 Jun 2009
Total Posts: 1681
02 Aug 2013 12:25 PM
^ That didn't work either... I added it to the all of the scripts inside of the bricks.
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
02 Aug 2013 01:09 PM
Have you tried using REMS?

Also, if it didn't make output, you can do:

ypcall(function()
error("This is zum output", 0)
end)

in your scripts to 'get output to REMS' or whatever you'd call it.

- As, caktropolis.
Report Abuse
pearman is not online. pearman
Joined: 05 Jun 2009
Total Posts: 1681
02 Aug 2013 04:35 PM
^

- What is REMS/ What does it stand for?

- I don't think my script executes in online mode, so more output like that wouldn't help much. If the output displayed in Play Solo, it's probably something to do with how my code loads ( I could be wrong, I started Rbx.Lua 5 days ago).
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
03 Aug 2013 06:54 AM
REMS stands for Remote Error Monitoring System.

You can get it as a model from ROBLOX, developed by some Roblox administrator I've forgotten the name of.

http://www.roblox.com/Remote-Error-Monitoring-System-item?id=65774258


Because Roblox admins can and will limit our possibilities, only scripts with the EXACT same source will be able to use the .Error event of ScriptContext, meaning that REMS is capable of finding whatever errors might happen in your server-sided Scripts (not LocalScripts)

Also, if you don't get response from making a fake error at line 1, then there's surely something completely wrong. Remember, the more output you do, the more likely you'll be to find out where the bug is (as long as you don't overdo it and put output on every line or so)

- As, lerp a herb.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image