I’m trying to set up an admin panel using the new ban API and it’s not working.
Here’s the first script (local)
script.Parent.MouseButton1Up:Connect(function()
local PlayerName = script.Parent.Parent.PlayerName.Text
local Message = script.Parent.Parent.Message.Text
local Time = script.Parent.Parent.Time.Time.Value
game.ReplicatedStorage.Misc.BanPlayer:FireServer(PlayerName, Message, Time)
end)
I keep getting an error: “Config must contain field Duration with type number”
I tried many things such as tostring(), creating a number value and changing that to the inputted number, but still the same error. It only works when I directly enter the number into the function. (The way this is supposed to work is you enter the name, message and time and the player gets banned)
idk if this is it, but when I use BanAsync, it says the service is not live. It could be something in game settings but I don’t know as I am unfamiliar with the ban API.
Edit: the type of the duration is the issue so try typechecking it to make sure it is a number:
if type(Time) ~= "number" then
print("that is issue")
end
if this prints something, then the time value isnt a number and that would be what the issue is. Not sure how this would be wrong if you are using a numbervalue object (if you are using a stringvalue or something else change it to numbervalue), but that seems like the most likely issue.
Ok, then make sure you have a numberValue object, or just store the duration as a value in the script. All that means is the Time variable has and incorrect type (Ex: it could be a boolean or smth).
script.Parent.MouseButton1Up:Connect(function()
local PlayerName = script.Parent.Parent.PlayerName.Text
local Message = script.Parent.Parent.Message.Text
local Time = tonumber(script.Parent.Parent.Time.Text)
game.ReplicatedStorage.Misc.BanPlayer:FireServer(PlayerName, Message, Time)
end)
Tes it would, but before you do that, you may be entering everything wrong. Don’t enter duration = time, just enter time. Maje sure you are doing that with all the other parameters too