0% found this document useful (0 votes)
240 views4 pages

Roblox Player Control GUI Script

The document outlines a script for a Roblox game that creates a user interface for controlling a player's character. It includes features like selecting a player, toggling control and spectate modes, and buttons for movement and jumping. The script utilizes GUI elements and event connections to manage player interactions and camera behavior in the game environment.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
240 views4 pages

Roblox Player Control GUI Script

The document outlines a script for a Roblox game that creates a user interface for controlling a player's character. It includes features like selecting a player, toggling control and spectate modes, and buttons for movement and jumping. The script utilizes GUI elements and event connections to manage player interactions and camera behavior in the game environment.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

-- Serviços

local Players = game:GetService("Players")


local RunService = game:GetService("RunService")
local Camera = [Link]

local player = [Link]

-- Criar ScreenGui
local screenGui = [Link]("ScreenGui")
[Link] = "ExecutorControlPlayerGui"
[Link] = player:WaitForChild("PlayerGui")

-- Criar Frame principal


local controlFrame = [Link]("Frame")
[Link] = "ControlFrame"
[Link] = [Link](0, 300, 0, 450)
[Link] = [Link](0.05, 0, 0.2, 0)
[Link] = 1
[Link] = screenGui

-- Função para criar botão


local function createButton(name, position, text)
local btn = [Link]("TextButton")
[Link] = name
[Link] = [Link](0, 60, 0, 60)
[Link] = position
btn.BackgroundColor3 = [Link](30, 30, 30)
[Link] = text
[Link] = true
btn.TextColor3 = [Link](255, 255, 255)
[Link] = controlFrame

local uicorner = [Link]("UICorner")


[Link] = [Link](0.3, 0)
[Link] = btn

local uistroke = [Link]("UIStroke")


[Link] = [Link](0, 255, 255)
[Link] = 2
[Link] = btn

return btn
end

-- Criar Dropdown
local dropdown = [Link]("TextButton")
[Link] = "Dropdown"
[Link] = [Link](0, 200, 0, 40)
[Link] = [Link](0, 0, 0, 0)
dropdown.BackgroundColor3 = [Link](40, 40, 40)
[Link] = "Selecionar Jogador"
[Link] = true
dropdown.TextColor3 = [Link](1, 1, 1)
[Link] = controlFrame

local uicornerDropdown = [Link]("UICorner", dropdown)


[Link] = [Link](0.3, 0)

local uistrokeDropdown = [Link]("UIStroke", dropdown)


[Link] = [Link](0, 255, 255)
[Link] = 2

local dropdownFrame = [Link]("Frame")


[Link] = [Link](0, 200, 0, 0)
[Link] = [Link](0, 0, 0, 40)
dropdownFrame.BackgroundColor3 = [Link](20, 20, 20)
[Link] = true
[Link] = controlFrame

-- Lista de jogadores
local function updateDropdown()
for _, obj in ipairs(dropdownFrame:GetChildren()) do
if obj:IsA("TextButton") then obj:Destroy() end
end

for i, p in ipairs(Players:GetPlayers()) do
if p ~= player then
local btn = [Link]("TextButton")
[Link] = [Link](1, 0, 0, 30)
[Link] = [Link](0, 0, 0, (i-1)*30)
btn.BackgroundColor3 = [Link](40, 40, 40)
[Link] = [Link]
btn.TextColor3 = [Link](1,1,1)
[Link] = true
[Link] = dropdownFrame

btn.MouseButton1Click:Connect(function()
[Link] = [Link]
selectedPlayer = p
dropdownFrame:TweenSize([Link](0,200,0,0), "Out",
"Quad", 0.2, true)
end)
end
end
end

dropdown.MouseButton1Click:Connect(function()
if [Link] == 0 then
updateDropdown()
dropdownFrame:TweenSize([Link](0,200,0,150), "Out", "Quad", 0.2,
true)
else
dropdownFrame:TweenSize([Link](0,200,0,0), "Out", "Quad", 0.2, true)
end
end)

-- Toggle de Controle
local toggleControlBtn = [Link]("TextButton")
[Link] = [Link](0, 200, 0, 40)
[Link] = [Link](0, 0, 0, 200)
toggleControlBtn.BackgroundColor3 = [Link](30, 30, 30)
[Link] = "Controle: OFF"
[Link] = true
toggleControlBtn.TextColor3 = [Link](255, 255, 255)
[Link] = controlFrame

local uicornerToggle = [Link]("UICorner", toggleControlBtn)


[Link] = [Link](0.3, 0)
local uistrokeToggle = [Link]("UIStroke", toggleControlBtn)
[Link] = [Link](0, 255, 255)
[Link] = 2

local controlEnabled = false


toggleControlBtn.MouseButton1Click:Connect(function()
controlEnabled = not controlEnabled
[Link] = "Controle: " .. (controlEnabled and "ON" or "OFF")
end)

-- Toggle de Spectate
local toggleSpectateBtn = [Link]("TextButton")
[Link] = [Link](0, 200, 0, 40)
[Link] = [Link](0, 0, 0, 250)
toggleSpectateBtn.BackgroundColor3 = [Link](30, 30, 30)
[Link] = "Spectate: OFF"
[Link] = true
toggleSpectateBtn.TextColor3 = [Link](255, 255, 255)
[Link] = controlFrame

local uicornerSpectate = [Link]("UICorner", toggleSpectateBtn)


[Link] = [Link](0.3, 0)

local uistrokeSpectate = [Link]("UIStroke", toggleSpectateBtn)


[Link] = [Link](0, 255, 255)
[Link] = 2

local spectateEnabled = false


toggleSpectateBtn.MouseButton1Click:Connect(function()
spectateEnabled = not spectateEnabled
[Link] = "Spectate: " .. (spectateEnabled and "ON" or "OFF")
end)

-- Criar botões de controle


local upBtn = createButton("Up", [Link](0.33, 0, 0.33, -60), "↑")
local downBtn = createButton("Down", [Link](0.33, 0, 0.66, 0), "↓")
local leftBtn = createButton("Left", [Link](0, 0, 0.5, -30), "←")
local rightBtn = createButton("Right", [Link](0.66, 0, 0.5, -30), "→")
local jumpBtn = createButton("Jump", [Link](0.33, 0, 0.5, -30), "🦘")

-- Movimento real do player


local moveSpeed = 8
local moveDir = [Link]()

[Link]:Connect(function()
if controlEnabled and selectedPlayer and [Link] then
local hrp = [Link]:FindFirstChild("HumanoidRootPart")
local humanoid =
[Link]:FindFirstChildOfClass("Humanoid")
if hrp and humanoid then
[Link] = [Link] + (moveDir * moveSpeed *
[Link]:Wait())
end
if spectateEnabled then
local targetHRP =
[Link]:FindFirstChild("HumanoidRootPart")
if targetHRP then
[Link] = [Link]
[Link] = [Link] * [Link](0, 2, 6)
end
else
[Link] = [Link]
end
end
end)

-- Eventos dos botões


upBtn.MouseButton1Down:Connect(function() moveDir = [Link](0, 0, -1) end)
upBtn.MouseButton1Up:Connect(function() moveDir = [Link]() end)

downBtn.MouseButton1Down:Connect(function() moveDir = [Link](0, 0, 1) end)


downBtn.MouseButton1Up:Connect(function() moveDir = [Link]() end)

leftBtn.MouseButton1Down:Connect(function() moveDir = [Link](-1, 0, 0) end)


leftBtn.MouseButton1Up:Connect(function() moveDir = [Link]() end)

rightBtn.MouseButton1Down:Connect(function() moveDir = [Link](1, 0, 0) end)


rightBtn.MouseButton1Up:Connect(function() moveDir = [Link]() end)

jumpBtn.MouseButton1Click:Connect(function()
if controlEnabled and selectedPlayer and [Link] then
local humanoid =
[Link]:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid:ChangeState([Link])
end
end
end)

You might also like