I need help debugging a ban system that relies on a datastore + improving it

Alright I’ve found the problem, it seems that it was printing “BAN A PLAYER”. That only means that there is something wrong in the LocalScript.

However, even then, it still keeps printing “UserId not founded”.

1 Like

Can you show me the GUI in the explorer?

-- VARIABLES

local RS = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer
local SGUI = script.Parent.Parent.Parent
local Button = SGUI.ScrollingFrame:WaitForChild("BanPlayer")
local banEvent = RS.BanEvent
local debounce = false
local PGUI = Player:WaitForChild("PlayerGui")

--EVENT

Button.MouseButton1Click:Connect(function()
	local text = PGUI.AdminPanel.ScrollingFrame.BanBox
	if debounce == false then
		debounce = true
		print("SUCCESS")
		banEvent:FireServer(text.Text)
		task.wait(0.25)
		debounce = false
	end
end)

The text variable is a TextBox, so that I can type in it.

No I mean the explorer window with the GUI, not the script

8b50364d8b20527b801a4279c9ec2b81
The GUI is located in StarterGui. The most important parts here is BanPlayer and BanBox.

Your local script also seems fine. Are you sure there aren’t any duplicates of the BanBox or the AdminPanel?

There are no duplicates of BanBox or AdminPanel in StarterGui.

Maybe change your variables to be “relative” to the script just in case there somehow are duplicates. I am guessing the local script you sent is called ClickScript?

The script I sent is the one inside BanPlayer button.

1 Like

Try this instead

local RS = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer
local SGUI = script.Parent.Parent.Parent
local Button = script.Parent
local banEvent = RS.BanEvent
local debounce = false

--EVENT

Button.MouseButton1Click:Connect(function()
	local text = SGUI.ScrollingFrame.BanBox
	print(text.Name)
	print(text.Text)
	if debounce == false then
		debounce = true
		print("SUCCESS")
		banEvent:FireServer(text.Text)
		task.wait(0.25)
		debounce = false
	end
end)

It doesn’t look like a lot has changed, since the output is still printing that “UserId not found!” Should I test in game?

Studio should be fine. Did the print(text.Text) inside of the localscript still say “BAN A PLAYER”?

No, it stopped printing “BAN A PLAYER” however “UserId not found” still prints, even after I put in the Player’s name.

What does text.Text print? Also, you can try testing it in game although I am not sure if it will make a difference.

The text.Text prints what I type in the box.

It might be my UserId function, give me a few minutes to test it

Are there any orange lines under the function I sent earlier? I forgot to add an end to it

Yes, but I put a end there so it’s all good.

I just noticed a typo in the script. Also, I tested the UserId function and it worked fine for me.

if target == nil then --i accidentally wrote taget
	warn("UserId not found!")
	return
end

That also was fixed eariler, what should I do to fix the script?