You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
A functioning ban panel that will effectively ban said user for said amount of time.
- What is the issue? Include screenshots / videos if possible!
When I try to ban another account, it doesn’t ban the other user and instead bans me.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have used the developer hub to help with DSes as well as RemoteEvents. I haven’t tried much, I don’t have a great idea of why my Script won’t work.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
LocalScript code, inside of a TextButton
script.Parent.MouseButton1Click:Connect(function()
local usr = tostring(script.Parent.Parent.Username.Text)
local rsn = tostring(script.Parent.Parent.Time.Text)
local banTime = tostring(script.Parent.Parent.Reason.Text)
game.ReplicatedStorage.BanUser:FireServer(usr, rsn, banTime)
end)
ServerScript code, inside of ServerScriptService
local function banUser(user, usr, rsn, banTime)
local dataStore = game:GetService("DataStoreService")
local bansStore = dataStore:GetDataStore("BansStore")
bansStore:SetAsync(usr.."user", usr)
bansStore:SetAsync(usr.."reason", rsn)
bansStore:SetAsync(usr.."status", true)
user:Kick("You are banned from Fenix Hotels.\nReason: "..rsn.."\n You will be unbanned in "..banTime.." day(s)")
local currentBanTime = os.time()
local daysToSecs = banTime * 86400
local timeAtUnban = tonumber(currentBanTime) + tonumber(daysToSecs)
bansStore:SetAsync(usr.."time", banTime)
bansStore:SetAsync(usr.."timeAtUnban", timeAtUnban)
print("!!BAN LOG!!", usr, "was banned for", rsn, "and will be unbanned in", banTime, "day(s)")
end
game.Players.PlayerAdded:Connect(function(plr)
local usr = plr.Name
local dataStore = game:GetService("DataStoreService")
local bansStore = dataStore:GetDataStore("BansStore")
local usr = bansStore:GetAsync(usr.."user")
local banStatus = bansStore:GetAsync(usr.."status")
local banReason = bansStore:GetAsync(usr.."reason")
local timeAtUnban = bansStore:GetAsync(usr.."timeAtUnban")
local banTimeRemaining = bansStore:GetAsync(usr.."time")
local currentTime = os.time()
if banStatus == true and usr == plr.Name and timeAtUnban > currentTime then
plr:Kick("You are banned from Fenix Hotels.\nReason: "..banReason.."\n You will be unbanned in "..banTimeRemaining.." day(s)")
else
return false
end
end)
game.ReplicatedStorage.BanUser.OnServerEvent:Connect(banUser)
Any Ideas?
(My bad if any parts are inefficient, I wrote the majority late at night.)