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

[SOLVED] How do i fix the walkspeed?

Same script as before i just added another command into it.. and another issue popped out output says problem in line 89 and 63 after stack begining

local commands = {}

local prefix = "/"

local admins = {
	"GamerOx_23"
}

local function findPlayer(name)
    for i, player in pairs(game.Players:GetPlayers()) do
        if string.lower(player.Name) == name then
            return player
        end
    end

    return nil
end

local function isAdmin(player)
	for _, v in pairs(admins) do
		if v == player.Name then
			return true
		end
	end
	
	return false
end

commands.tp = function(sender, arguments)
    print("TP Function fired by" .. sender.Name)

    for i, playerName in pairs(arguments) do
        print(playerName)
    end

    local playerToTeleportName = arguments[1]
    local playerToTeleportToName = arguments[2]

    if playerToTeleportName and playerToTeleportName then
        local plrToTP = findPlayer(playerToTeleportName)
        local plrToTpTo = findPlayer(playerToTeleportName)

        if plrToTP and plrToTpTo then
            plrToTP.Character:WaitForChild("HumanoidRootPart").CFrame =
                plrToTpTo.Character:WaitForChild("HumanoidRootPart").CFrame
            print("It fricking worked")
        end
    end
end

commands.speed = function(sender, arguments) --"/speed me 30" ---> arguments["me","30"]
	
	print("Speed command fire by "..sender.Name)
	
	local playerToGiveSpeedTo = arguments[1]
	local amountOfSpeedToGive = arguments[2]
	
	
	if playerToGiveSpeedTo then
		local plr = findPlayer(playerToGiveSpeedTo)
		
		if plr then
			plr.Character.Humanoid.WalkSpeed = tonumber(amountOfSpeedToGive)
			print(playerToGiveSpeedTo.." was given Walkspeed".. amountOfSpeedToGive)
		end	
	end
end

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message, recipient)
		if isAdmin(player) then	
		message = string.lower(message)

        local splitString = message:split(" ")

        local slashCommand = splitString[1]

        local cmd = slashCommand:split(prefix)

        local cmdName = cmd[2]

        if commands[cmdName] then
			local arguments = {}

            for i = 2, #splitString, 1 do
                        table.insert(arguments, splitString[i])
            end

			 commands[cmdName](player, arguments)
			
		end

			end
		end)
    end)

2 comments

0

i fixed it please ignore this question!

0

You should put "[Solved]" in the title so people know.

1 answer

In the IsAdmin() function, you are returning true but then when it leaves the function it changes to false. You should use else instead.

2 comments

0

but that has nothing to do with line 63 and 89 tho?

0

18:24:32.162 - Stack Begin 18:24:32.163 - Script 'ServerScriptService.admincmd', Line 63 18:24:32.163 - Script 'ServerScriptService.admincmd', Line 89 18:24:32.164 - Stack End

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