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

How I change property of GUI with another script?

I have 2 script 1.(game.StarterGui.ScreenGui.Frame.ChickenMan.Script)-change team script

`local player = script.Parent.Parent.Parent.Parent.Parent
Frame = script.Parent.Parent
local gui = game.StarterGui.ScreenGui.TeleportButton

script.Parent.MouseButton1Click:connect(function()
gui.Visible = true
player.Team = game.Teams:FindFirstChild("ChickenMan")
player.Character.Humanoid.Health = 0
Frame.Position = (UDim2.new(0.5,0,-0.5,0))
game.Workspace.Teleport.RemoteFunction:InvokeServer()
end)`

2.(game.StarterGui.ScreenGui.TeleportButton.LocalScript)- teleport script

 local disabled = false
local player = script.Parent.Parent.Parent.Parent

script.Parent.MouseButton1Click:connect(function()
if disabled == false then
disabled = true
script.Parent.BackgroundColor3 = Color3.new(217, 0, 0)
game.Workspace.Teleport.RemoteFunction:InvokeServer()
wait(3)
script.Parent.BackgroundColor3 = Color3.new(0, 154, 0)
disabled = false
end
end)

in first TeleportButton.visible = false i want to set TeleportButton.visible = true in script1 but my script isn't work ,what wrong in my script Can you help me,pls thank this is a photo

3 answers

What seemed to be the problem is this variable you stored. local gui = game.StarterGui.ScreenGui.TeleportButton

People tend to do this same kind of mistake, they use the service StarterGui when it does nothing at all but to only 'serve' (PlayerReplicated) the players every child of the StarterGui into the players' PlayerGui. So any GuiObject inside the StarterGui will be PlayerReplicated into the Player's PlayerGui

Therefore, your variable should be local gui = player:WaitForChild("PlayerGui")

he got a point in that but if u want to access the same thing as ur trying to access in ur script then u should change local gui = game.StarterGui.ScreenGui.TeleportButton to local gui = game.Players.LocalPlayer:WaitForChild("PlayerGui").ScreenGui.TeleportButton

that will access the local players screen and the exact same part of the screen as u tried to access in ur own script

2 comments

0

PlayerGui / GuiObjects can't replicate to the server 'anymore'. In logic, if you want to access GuiObject in the server scripts then a ValueObject that is inserted in the server itself then it might work, but in this case; no since he/she is trying to use a 'TextButton'.

0

if it is a local script that is trying to access it then yes it will work, its just a server script that cant access the gui

hey everyone thank for Gameplayer365247v2 and NickAtNick's comment but it can't be use. and i don't good at code so please help me more a lot of thank you???????????? (Gameplayer365247v2 and NickAtNick script when i run it don't have anything happen)

1 comment

0

(a lot of thank you)

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