Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

why is args[2] nil in this announce script?

local args = script.Parent.Parent.Text:split(" ")

script.Parent.ya.OnServerEvent:Connect(function()
    script.Parent.Parent.Parent.announcemnet.Visible = true
    script.Parent.Parent.Parent.announcemnet:TweenPosition(
        UDim2.new(0.373, 0, 0.364, 0),
        "In",
        "Quad",
        0.4,
        true
        )
    script.Parent.Parent.Parent.announcemnet.yes.Text = args[2]
    
    local blur = Instance.new("BlurEffect")
    blur.Size = 24
    blur.Enabled = true
    blur.Parent = game.Workspace.Camera
    wait(9)
    blur.Size = 23
        wait(0.2)
    blur.Size = 22
        wait(0.2)
    blur.Size = 21
        wait(0.2)
    blur.Size = 20
        wait(0.2)
    blur.Size = 19
        wait(0.2)
    blur.Size = 18
        wait(0.2)
    blur.Size = 17
        wait(0.2)
    blur.Size = 16
        wait(0.2)
    blur.Size = 15
        wait(0.2)
    blur.Size = 14
        wait(0.2)
    blur.Size = 13
        wait(0.2)
    blur.Size = 12
        wait(0.2)
    blur.Size = 11
        wait(0.2)
    blur.Size = 10
        wait(0.2)
    blur.Size = 9
        wait(0.2)
    blur.Size = 8
        wait(0.2)
    blur.Size = 7
        wait(0.2)
    blur.Size = 6
        wait(0.2)
    blur.Size = 5
        wait(0.2)
    blur.Size = 4
        wait(0.2)
    blur.Size = 3
        wait(0.2)
    blur.Size = 2
        wait(0.2)
    blur.Size = 1
        wait(0.2)
    blur.Enabled = false
    
    script.Parent.Parent.Parent.announcemnet:TweenPosition(
        UDim2.new(0.374, 0, -0.3, 0),
        "In",
        "Quad",
        0.4,
        true
        )
    wait(0.5)
    script.Parent.Parent.Parent.announcemnet.Visible = false
end)

normal script

local tecks = script.Parent

tecks.FocusLost:Connect(function()
	local args = tecks.Text:split(" ")
	
	if args[1] == "announce" then
		script.ya:FireServer()
	end	
end)

local script

i get the error: Players.KoffeKiten.PlayerGui.Yes yes yes.CommandBar.announcemnet.Script:12: invalid argument #3 (string expected, got nil)

2 comments

0

Does the string even have a whitespace?

0

is there a space after "announce" inside the box?

1 answer

There's a lot of things wrong with this. The error is saying that "args" doesn't exist. This is just using a textbox and a button. (this is mostly just an example, it doesn't have any security against exploiters)

playergui:

script.Parent.MouseButton1Click:Connect(function()
	local args = script.Parent.Parent.TextBox.Text
	game.ReplicatedStorage.ya:FireServer(args)
end) 

serverscriptstorage:

game.ReplicatedStorage.ya.OnServerEvent:Connect(function(plr, text)
	game.ReplicatedStorage.ya:FireAllClients(plr.Name, text)
end)

starterplayerscripts:

game.ReplicatedStorage.ya.OnClientEvent:Connect(function(plr, text)
	game.Players.LocalPlayer.PlayerGui.Announcement.Frame.Visible = true
	game.Players.LocalPlayer.PlayerGui.Announcement.Frame:TweenPosition(
		UDim2.new(0.373, 0, 0.364, 0),
		"In",
		"Quad",
		0.4,
		true
	)
	game.Players.LocalPlayer.PlayerGui.Announcement.Frame.TextLabel.Text = "Announcement by "..plr..": "..text

	local blur = Instance.new("BlurEffect")
	blur.Size = 24
	blur.Enabled = true
	blur.Parent = game.Workspace.Camera
	wait(9)
	blur.Size = 23
	wait(0.2)
	blur.Size = 22
	wait(0.2)
	blur.Size = 21
	wait(0.2)
	blur.Size = 20
	wait(0.2)
	blur.Size = 19
	wait(0.2)
	blur.Size = 18
	wait(0.2)
	blur.Size = 17
	wait(0.2)
	blur.Size = 16
	wait(0.2)
	blur.Size = 15
	wait(0.2)
	blur.Size = 14
	wait(0.2)
	blur.Size = 13
	wait(0.2)
	blur.Size = 12
	wait(0.2)
	blur.Size = 11
	wait(0.2)
	blur.Size = 10
	wait(0.2)
	blur.Size = 9
	wait(0.2)
	blur.Size = 8
	wait(0.2)
	blur.Size = 7
	wait(0.2)
	blur.Size = 6
	wait(0.2)
	blur.Size = 5
	wait(0.2)
	blur.Size = 4
	wait(0.2)
	blur.Size = 3
	wait(0.2)
	blur.Size = 2
	wait(0.2)
	blur.Size = 1
	wait(0.2)
	blur.Enabled = false

	game.Players.LocalPlayer.PlayerGui.Announcement.Frame:TweenPosition(
		UDim2.new(0.374, 0, -0.3, 0),
		"In",
		"Quad",
		0.4,
		true
	)
	wait(0.5)
	game.Players.LocalPlayer.PlayerGui.Announcement.Frame.Visible = false
end)	

This discussion is preserved as it was. New answers, comments, and votes are closed.