Are you testing this in a regular roblox server or studio?
Are you using a part to click on or a GUI? Because on your picture you seemed to be using a GUI in the client. The other picture was for a part with clickdetector
A roblox server as I knew that it could mess it up if you used studio
I am using a brick to click on
Are you sure there are no errors at all both on the Client
side and Server
side?
Just learned clicking isnt even changing the value to true and here is the name it is called value but your calling it by boolvalue
Ah, my bad.
This should be the script inside the ServerScriptService
.
local DataStoreService = game:GetService("DataStoreService");
local DataStore = DataStoreService:GetDataStore("BannedDataStore");
game.Players.PlayerAdded:Connect(function(player)
local boolval = Instance.new("BoolValue", player)
boolval.Value = DataStore:GetAsync(player.UserId) or false
if boolval.Value == true then
player:Kick("Banned.")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
DataStore:SetAsync(player.UserId, player:FindFirstChild("Value").Value)
end)
And this should be the click brick script. (Make sure it has a click detector inside of it named ClickDetector
.)
script.Parent.ClickDetector.MouseButton1Click:Connect(function(player)
player:FindFirstChild("Value").Value = true
end)
I really suggest you however remove the bookvalue entirely and instead save the bans within a table located in the script that loads and saves the ban. It’s more reliable, and also safer from possible exploits.
Like I said before:
Bans={}
—someone joins
Bans[player.userid]=datastore:getasync(user id)
—someone leaves
Saves the value located in table and removes that entry from table
And the button should instead of changing the value instance, change the value in table
It works now! But how do I unban? EDIT: I have datastore editor
Since you have Data store editor, in that case, you may search for the userID if that player, and change the value to false
Thanks so much, I am so sorry for my lack of knowledge I will 100% get into learning more about that your answer is now marked as a solution!
That’s fine. You can’t just magically learn everything in a day. Learning is a process we all experience and no one actually stops experiencing it. No matter how good you get, you can always improve
Quick last question before you go where did you both learn scripting?
I learned most of it between 2010-2016 via the RŌBLOX wiki, and experimenting. Reading the wiki let’s you understand how something works, like a function or such. And well, most of the learning tbh is by experimenting the more you code. The more you learn. I stopped scripting between 2016-2018 and when I came back I was so rusty, and today I still am pretty outdated on the new RŌBLOX features, so I still learn everyday
I learned scripting first off youtube, then off free model scripts, then I used the dev wiki more and more and the developer forum to the point where I don’t use youtube or free models anymore for learning lua.
I sent you a private message if you could check that out!