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

Admin Script for some reason not working?, speed command loops back to kill command

Hey guys! I'm currently experiencing and issue in where my admin script that i'm using to parse the text isn't working even though the Args doesn't match the command. Here's the script

local function Parse(Text)
	print("At the start")
	local args = Text:split(" ")
	print(args[1])
	print(args[2])
	print(args[3])
	if args[1] == "kill" or "Kill" then
		print("Kill")
		if game.Players:FindFirstChild(args[2]) then
			game.Players:FindFirstChild(args[2]).Character.Humanoid.Health = 0
			Output.Text = ("Killed "..tostring(args[2]))
			Passed()
		else
			Output.Text = ("Player Not Found, "..tostring(args[2]))
			Failed()
		end
	elseif args[1] == "Speed" or "speed" or "Walkspeed" or "walkspeed" or "WalkSpeed" then
		if game.Players:FindFirstChild(args[2]) then
			if args[3] then
				print("Speed")
				game.Players:FindFirstChild(args[2]).Character.Humanoid.WalkSpeed = tonumber(args[3])
				Passed()
			else
				Output.Text = ("Invalid Argument, "..tostring(args[3]))
				Failed()
			end
		else
			Output.Text = ("Player Not Found, "..tostring(args[2]))
			Failed()
		end
	end
end

When i use the kill command, it works just fine. However, when i use the speed command it plays the kill command instead. Everything prints correctly. When i use the print command it prints "Speed" then "Kill" and kills me. Anyone know why its looping back to kill? It only prints at the start once, and not again when i do the speed command (which kills me)

1 answer

Ok I see what you did wrong.

The problem is that you cannot use or like:

if string == "speed" or "Speed" then

You must use it like:

if string == "speed" or string == "Speed" then

because (In the first example) "Speed" is not a nil value so it will run it

Here's the script that worked for me:


local function Parse(Text)
	print("At the start")
	local args = Text:split(" ")
	print(args[1])
	print(args[2])
	print(args[3])
	if args[1] == "kill" then
		print("Kill")
		if game.Players:FindFirstChild(args[2]) then
			game.Players:FindFirstChild(args[2]).Character.Humanoid.Health = 0
		else
			Output.Text = ("Player Not Found, "..tostring(args[2]))
			
		end
	elseif args[1] == "Speed" or args[1] == "speed" or args[1] == "Walkspeed" or args[1] == "walkspeed" or args[1] == "WalkSpeed" then
		if game.Players:FindFirstChild(args[2]) then
			if args[3] then
				print("Speed")
				game.Players:FindFirstChild(args[2]).Character.Humanoid.WalkSpeed = tonumber(args[3])
				
			else
				Output.Text = ("Invalid Argument, "..tostring(args[3]))
				
			end
		else
			Output.Text = ("Player Not Found, "..tostring(args[2]))
			
		end
	end
end


I removed the Failed and Passed functions I hope thats ok.

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