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
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
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.
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.