I have a game, and it includes two teams. There are some values I'm not sure about, but anywho, the game without this first localscript placed in the StarterGUI will not make the entire game work. I received two errors when trying to use a tool where I wanted to clone a GUI.
Errors:
I also have the scripts that correlate to each.
Error Script:
local tool = script.Parent
local plr = game.Players.LocalPlayer
local gui1 = game.ReplicatedStorage.ControlsGui
local controlsGui = plr.PlayerGui:FindFirstChild("ControlsGui")
tool.Equipped:connect(function()
tool.rMovement.Disabled=true
tool.lMovement.Disabled=true
if plr and tool.Parent:findFirstChild("Humanoid") and not controlsGui then
controlsGui=gui1:Clone()
controlsGui.Parent=plr.PlayerGui --considered Line 29
end
controlsGui:WaitForChild('TextButton').Visible = true
if tool.HandValue.Value==1 then
tool.lMovement.Disabled=false
else tool.rMovement.Disabled=false
end
end)
Warning Script:
local player = game.Players.LocalPlayer
local playerTool = script.Parent
local playerGui = player:WaitForChild('PlayerGui')
local controlGui = playerGui:WaitForChild('ControlsGui')
local txtBttn = controlGui:WaitForChild('TextButton')
local Debounce = true
local Active = false -- Rewritten
local CoolDown = 0.01
function Start()
playerTool.rMovement.Disabled=true
playerTool.lMovement.Disabled=true
playerTool.HandValue.Value = 1
playerTool.GripPos = Vector3.new(0.5, -0.5, -0.3)
wait(0.01)
playerTool.GripPos = Vector3.new(0.5, -1, 0)
wait(0.01)
playerTool.GripPos = Vector3.new(0.5, -1.5, 0.5)
wait(0.01)
playerTool.GripPos = Vector3.new(0.5, -1.5, 1)
wait(0.01)
playerTool.GripPos = Vector3.new(0.5, -1.5, 1.5)
wait(0.01)
playerTool.GripPos = Vector3.new(0.5, -1, 2)
wait(0.01)
playerTool.GripPos = Vector3.new(1, -0.5, 2.5)
wait(0.01)
playerTool.GripPos = Vector3.new(1.5, 0, 3)
wait(0.01)
playerTool.GripPos = Vector3.new(2, 0.5, 3)
wait(0.01)
playerTool.GripPos = Vector3.new(2.5, 1, 3)
wait(0.01)
playerTool.GripPos = Vector3.new(3, 1.5, 3)
wait(0.01)
playerTool.GripPos = Vector3.new(2.5, 2, 2.5)
wait(0.01)
playerTool.GripPos = Vector3.new(2, 2.5, 2)
wait(0.01)
playerTool.GripPos = Vector3.new(1.5, 3, 1.5)
wait(0.01)
playerTool.GripPos = Vector3.new(1, 3.5, 1)
wait(0.01)
playerTool.GripPos = Vector3.new(0.5, 3, 0.5)
wait(0.01)
playerTool.GripPos = Vector3.new(0.5, 2.5, 0)
wait()
playerTool.lMovement.Disabled=false
end
playerTool.Unequipped:Connect(function()
if controlGui and controlGui:FindFirstChild('TextButton') then
-- constantly update it so that it's accurate.
controlGui.TextButton.Visible = false
end
end)
txtBttn.MouseButton1Down:connect(function()
if Debounce then
Debounce = false
Start()
wait(CoolDown)
Debounce = true
end
end)
function onKeyPress(actionName, userInputState, inputObject)
if userInputState == Enum.UserInputState.Begin then
if Active and Debounce then
Debounce = false
Start()
wait(CoolDown)
Debounce = true
end
end
end
game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.G)
And here's the script that runs the entire game:
PLAYERS=workspace.PLAYERS
player=script.Parent.Parent
gui=game.StarterGui
wait(1)
if player:findFirstChild("inhere") then
wait()
else
local d=Instance.new("ObjectValue") --might have an importance due to why the GUI won't show up.
d.Parent=player
d.Name="inhere"
local s=Instance.new("NumberValue")
s.Parent=player
s.Name="playernumber"
gui.AllPoints:clone().Parent=player
gui.Points:clone().Parent=player
gui.ShotsA:clone().Parent=player
gui.ShotsM:clone().Parent=player
wait()
if player.TeamColor==BrickColor.new("Bright red") then
gui.Red:clone().Parent=player.Character.Torso
if PLAYERS.RED.one.Value~="" then
if PLAYERS.RED.two.Value~="" then
if PLAYERS.RED.three.Value~="" then
if PLAYERS.RED.four.Value~="" then
wait(1)
else
PLAYERS.RED.four.Value=player.Name
player.playernumber.Value=4
end
else
PLAYERS.RED.three.Value=player.Name
player.playernumber.Value=3
end
else
PLAYERS.RED.two.Value=player.Name
player.playernumber.Value=2
end
else
PLAYERS.RED.one.Value=player.Name
player.playernumber.Value=1
end
elseif player.TeamColor==BrickColor.new("Bright blue") then
gui.Blue:Clone().Parent=player.Character.Torso
if PLAYERS.BLUE.one.Value~="" then
if PLAYERS.BLUE.two.Value~="" then
if PLAYERS.BLUE.three.Value~="" then
if PLAYERS.BLUE.four.Value~="" then
wait()
else
PLAYERS.BLUE.four.Value=player.Name
player.playernumber.Value=4
end
else
PLAYERS.BLUE.three.Value=player.Name
player.playernumber.Value=3
end
else
PLAYERS.BLUE.two.Value=player.Name
player.playernumber.Value=2
end
else
PLAYERS.BLUE.one.Value=player.Name
player.playernumber.Value=1
end
end
end
If none of these scripts helped, please contact me, I am really in need of fixing this GUI so that it can pop up in-game.
Sincerely, LukeGabrieI aka EnergyBrickz
