This script WAS working, until I added the GUI configuring parts to the script. This script is supposed to teleport the player to R2D when they chat "r2d" (With :lower()) This script is a regular script in a GUI:
game.Players.PlayerAdded:connect(function(plr) plr.Chatted:connect(function(msg) msg = msg:lower() if msg == "r2d" then script.Parent.TpName.Visible = true script.Parent.TpTo.Visible = true script.Parent.Frame.BackgroundTransparency = 0.8 wait(1) script.Parent.Frame.BackgroundTransparency = 0.6 wait(1) script.Parent.Frame.BackgroundTransparency = 0.4 wait(1) script.Parent.Frame.BackgroundTransparency = 0.2 wait(1) script.Parent.Frame.BackgroundTransparency = 0 wait(2) game:GetService("TeleportService"):Teleport(147513144,plr) -- I didn't put the real R2D ID here. It's just a random ID to test this. end end) end)
Your script never checked against players that joined before the script started. Also, it's checking against all players even though it's only meant to check against one.
Here's my solution:
A script in workspace or ServerScriptService:
local Players=game:GetService("Players") local TeleportService=game:GetService("TeleportService") local GameID=163612261 function OnPlayerAdded(Player) -- add events to players local Event=Player:FindFirstChild("OnPlayerTeleporting") if not Event then Event=Instance.new("RemoteEvent",Player) Event.Name="OnPlayerTeleporting" end -- chat hook Player.Chatted:connect(function(Message) if Message:lower()=="r2d" then wait(1) TeleportService:Teleport(GameID,Player) end end) end Players.PlayerAdded:connect(OnPlayerAdded) -- handle players connected before the script loaded for i,v in pairs(Players:GetPlayers()) do OnPlayerAdded(v) end
A localscript in a screengui, with a frame:
-- localscript in a playergui that contains a frame - handles gui animations only local Gui=script.Parent local Frame=Gui:WaitForChild("Frame") local Player=game:GetService("Players").LocalPlayer local Event=Player:WaitForChild("OnPlayerTeleporting") Event.OnClientEvent:connect(function() for i=1,0,-0.1 do Frame.BackgroundTransparency=i wait(0.1) end end)