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

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

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

✓ Accepted answer
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

8 comments

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!

0

:D

0

Well at least it worked in Studio, It doesn't seem to work in the actual game OwO

0

Is the game filtering enabled?

0

Yeah

0

Try putting a local script in startergui and at the bottom change it to the location of the brick

0

Thank you it worked ^^

0

<3

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.

1 comment

0

Where do I need to add the localscript?

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.

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