I created a multiscript world teleporting GUI but I cannot figure how the slightest bit to make it so when the text button is clicked it teleports the player. I have provided the script below that creates the gui.
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(char) local s = Instance.new("ScreenGui") s.Parent = player.PlayerGui local t = Instance.new("Frame") t.Parent = player.PlayerGui.ScreenGui local g = Instance.new("ScrollingFrame") g.Parent = player.PlayerGui.ScreenGui wait(.1) player.PlayerGui.ScreenGui.Frame.Size = UDim2.new(0, 1000,0, 700) player.PlayerGui.ScreenGui.Frame.BorderColor3 = Color3.new(170/255, 0/255, 0/255) player.PlayerGui.ScreenGui.Frame.BackgroundColor3 = Color3.new(0/255, 0/255, 0/255) player.PlayerGui.ScreenGui.Frame.BorderSizePixel = 20 player.PlayerGui.ScreenGui.ScrollingFrame.ScrollBarThickness = 15 player.PlayerGui.ScreenGui.ScrollingFrame.Size = UDim2.new(0, 400,0,600) player.PlayerGui.ScreenGui.ScrollingFrame.BackgroundColor3 = Color3.new(85/255, 37/255, 9/255) player.PlayerGui.ScreenGui.ScrollingFrame.BorderColor3 = Color3.new(27/255, 42/255, 53/255) player.PlayerGui.ScreenGui.ScrollingFrame.BottomImage = "rbxgameasset://Images/Work" player.PlayerGui.ScreenGui.ScrollingFrame.MidImage = "rbxgameasset://Images/Work" player.PlayerGui.ScreenGui.ScrollingFrame.TopImage = "rbxgameasset://Images/Work" local c = Instance.new("TextButton") c.Parent = player.PlayerGui.ScreenGui.ScrollingFrame player.PlayerGui.ScreenGui.ScrollingFrame.TextButton.Text = "Innovation Weapon Vault" player.PlayerGui.ScreenGui.ScrollingFrame.TextButton.BackgroundColor3 = Color3.new(0/255, 0/255, 255/255) player.PlayerGui.ScreenGui.ScrollingFrame.TextButton.Position = UDim2.new(0, 60,0, 30) player.PlayerGui.ScreenGui.ScrollingFrame.TextButton.TextWrapped = true player.PlayerGui.ScreenGui.ScrollingFrame.TextButton.Size = UDim2.new(0,200,0,100) player.PlayerGui.ScreenGui.ScrollingFrame.TextButton.FontSize = "Size18" end) end)
Here is the script that is suppose to teleport the player when "TextButton" is clicked
script.Parent.MouseButton1Down:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then game:GetService("TeleportService"):Teleport(334747890, player) end end)
I need to make it so that that player gets teleported.The error is the "Hit" and I have no clue how to fix it.(Yes I did create a world universe)
Why don't you just get the localplayer?
player = game.Players.LocalPlayer script.Parent.MouseButton1Down:connect(function() game:GetService("TeleportService"):Teleport(334747890, player) end)