Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How I change property of GUI with another script?

Asked by 5 years ago

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

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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

Ad
Log in to vote
0
Answered by 5 years ago

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

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'. NickAtNick 163 — 5y
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 Gameplayer365247v2 1055 — 5y
Log in to vote
0
Answered by 5 years ago

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)

0
(a lot of thank you) ggamerkung 0 — 5y

Answer this question