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

Why doesn't this make my TextLabel visible?

Asked by 4 years ago
Edited 4 years ago
script.Parent.Touched:Connect(function(h)
    local hum = h.Parent:FindFirstChild("Humanoid")
    if hum ~= nil then
        h.Parent.HumanoidRootPart.CFrame = CFrame.new(workspace["Teleporter1part2"].Position)
    local Intro = game.StarterGui.Message.Introduction
       Intro.Visible = true


    end
end)

I wanted to make the brick teleport you and then make the text label so you can see it but is not working pls help. Also, this is a regular script, not a local script

2 answers

Log in to vote
0
Answered by 4 years ago

The StarterGui is not what the player sees. It is simply how the server knows what to put in each player's PlayerGui.

You're gonna have to do this:

local player = game:GetService("Players"):GetPlayerFromCharacter(h.Parent)
player.PlayerGui.Message.Introduction.Intro.Visible = true
0
This didint work for me BlueFlash2020 5 — 4y
0
Then you did it wrong. hitonmymetatables 50 — 4y
0
Hit me up on discord for help mumble#0040 hitonmymetatables 50 — 4y
Ad
Log in to vote
0
Answered by
Despayr 505 Moderation Voter
4 years ago

Please use a code block next time.

Regular Scripts cannot access the PlayerGui. To achieve what you are aiming for, you can use RemoteEvents.

First, lets set everything up.

Place a local script inside of the intro frame

Regular Script

local replicatedstorage = game:GetService("ReplicatedStorage")
local event = replicatedstorage:FindFirstChild("ServerGuiAccess")
local plrservice =  game:GetService("Players")

if not event then
    event = Instance.new("RemoteEvent")
    event.Name = "ServerGuiAccess"
    event.Parent = replicatedstorage
end

local debounce = false

script.Parent.Touched:Connect(function(hit)

    if debounce == true then return end

    local plr = plrservice:GetPlayerFromCharacter(hit.Parent)
    if not plr then return end

    local humanoid = plr.Character:FindFirstChildOfClass("Humanoid")
    if not humanoid then return end

    debounce = true

    local tele = game.Workspace:FindFirstChild("Teleporter1part2")
    plr.Character:MoveTo(tele.Position) --shorter way of teleporting character

    event:FireClient(plr) -- sends a signal to the client

    wait(1)

    debounce = false

end)

Local Script

local replicatedstorage = game:GetService("ReplicatedStorage")
local event = replicatedstorage:WaitForChild("ServerGuiAccess")

event.OnClientEvent:Connect(function()
    script.Parent.Visible = true
end)

I have just written this outside of studio, so there may be errors.

0
This is actually false the server can access the PlayerGui, just not PlayerScripts as that is completely local. hitonmymetatables 50 — 4y
0
Idk what a code block is xD BlueFlash2020 5 — 4y
0
Don't take his advice, the server and regular scripts can access the PlayerGui just fine. hitonmymetatables 50 — 4y
0
If the server could not access it, then StarterGui would break. hitonmymetatables 50 — 4y

Answer this question