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

How to make an ImageLabel in a ScreenGui in the StarterGui pop up when a player touches a brick?

Asked by 6 years ago

So... In one of my games, I work with a teleport system, so if a player touches an invisible brick, he will be teleported to the place that's in the script in the part. But... I also want to make an ImageLabel in a ScreenGui in the StarterGui pop up when the player touches the brick, saying that he's being teleported. I tried to get in this Gui using the 'players' thing in the game, but I'm kinda stuck with the script... Can someone help me or show me another way to do this? Thanks a lot.

This is the script I made:

local TeleportService = game:GetService("TeleportService")
local gameID = 2198621137

function onTouched(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        TeleportService:Teleport(gameID, player)
        game.Players."I'm stuck here".PlayerGui.Revolution2004.ImageLabel.Visible = true
        print("Teleporting to Revolution 2004...")
    end
end

script.Parent.Touched:connect(onTouched)

? "Revolution2004" is the name of the ScreenGui

3 answers

Log in to vote
0
Answered by 6 years ago
local TeleportService = game:GetService("TeleportService")
local gameID = 2198621137
local debounce=false

function onTouched(hit)
    if game.Players:FindFirstChild(hit.Parent.Name) and debounce==false then
        debounce=true
        player = game.Players[hit.Parent.Name]
        TeleportService:Teleport(gameID, player)
        player.PlayerGui.Revolution2004.ImageLabel.Visible = true
        print("Teleporting to Revolution 2004...")
        wait(5)
        debounce=false
    end
end

script.Parent.Touched:connect(onTouched)

Hope this helped. <3

0
Thank you so much! At first, it didn't seem to work, but I found out that this had something to do with a property of the ScreenGui called 'IgnoreGuiInset'. Everything is working perfectly now! Dylan011444 59 — 6y
0
:D OkxieCorey 125 — 6y
0
Well at least it worked in Studio, It doesn't seem to work in the actual game OwO Dylan011444 59 — 6y
0
Is the game filtering enabled? OkxieCorey 125 — 6y
View all comments (4 more)
0
Yeah Dylan011444 59 — 6y
0
Try putting a local script in startergui and at the bottom change it to the location of the brick OkxieCorey 125 — 6y
0
Thank you it worked ^^ Dylan011444 59 — 6y
0
<3 OkxieCorey 125 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

If i am not wrong you cant access Players PlayerGui with script. However you can do that with remote events.

U need to insert a remote event into workspace and then create a localscript in starterplayer.

In LocalScript u write this code:

local remote = workspace.Remote --Remote name
remote.OnClientEvent:connect(function()
    game.Players.LocalPlayer.PlayerGui.Revolution2004.ImageLabel.Visible = true
end

and in script that should teleport:

local TeleportService = game:GetService("TeleportService")
local gameID = 2198621137
local event = workspace.Remote --Remote name

function onTouched(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        TeleportService:Teleport(gameID, player)
        event:FireClient(player)
        print("Teleporting to Revolution 2004...")
    end
end

script.Parent.Touched:connect(onTouched)

If it doesnt work tell me.

0
Where do I need to add the localscript? Dylan011444 59 — 6y
Log in to vote
0
Answered by 6 years ago

Check too see if the Humanoid touched a brick make the script local and make the script so it finds the gui and makes it visible.

Answer this question