I really have no clue what's wrong with this script, the Admin panel frame does not go visible. You can't click the players torso and the Player profile gui does not come up when you do.
And at the bottom of the script is where the donation system is, I am using a leader stat called cash. What's wrong with my script? Can you tell me what I was doing wrong and why it does not work?
wait() Admin = {"IntellectualBeing"} local pr = game.Players.LocalPlayer local Frame = script.Parent.Content.AdminPanel for i = 1, #Admin do if pr.Name == Admin[i] then Frame.Visible = true else Frame.Visible = false print('You do not have permission to view this!') end end local me = game.Players.LocalPlayer local mouse = me:GetMouse(); local FrameB = script.Parent.Content local Title = FrameB.Title plr = script.Parent.Player mouse.Button1Down:connect(function() if mouse.Target == "Part" and game.Players:GetPlayerFromCharacter(mouse.Target.Parent) then plr.Value = game.Players:GetPlayerFromCharacter(mouse.Target.Parent) if plr.Value~=nil then FrameB.Visible = true Title.Text = plr.Value.Name.."'s Profile" else end end end) repeat wait() until plr.Value ~= nil -- --Define variables just in case (Resetting) local Cash = me.leaderstats.Cash --Leaderstats is the stat holder inside the player local OCash = plr.Value["leaderstats"].Cash --For the player that the points are going too. local Dbutton = FrameB.Page.DonateButton local Input = FrameB.Page.Input Dbutton.Button1Down:connect(function() if Cash.Value <= tonumber(Input.Text) then Cash.Value = (Cash.Value - (tonumberInput.Text)) OCash.Value = (OCash.Value + (tonumberInput.Text)) end end)
Let's break this down in the problems you describe:
-Admin panel does not get visible -Cannot click players torso -GUI does not show up
-Admin panel does not get visible
This code looks good, actually. My guess is that you are testing locally. Your local player name is then not the name which you are logged in to, but Player1, Player2, etc. Just insert "Player1" in the admins table.
-Cannot click players torso
This has to do with that GUI not showing up. The problem is at this line:
if mouse.Target == "Part" and game.Players:GetPlayerFromCharacter(mouse.Target.Parent) then
mouse.Target is an instance. "Part" is a string. Therefore, these can never be equal.
(game.Workspace == "Workspace" is also false!)
In fact, every mouse.Target is a part (that is what I think you mean!). Therefore you can completely remove that statement and pack it into:
if game.Players:GetPlayerFromCharacter(mouse.Target.Parent) then
Now the GUI will show up!
However, your donation GUI will only work for one player, after that the script has ended. This check has to run forever and you must also make sure that you are not connecting a lot of events to the same button, because then if you donate 10 cash to someone and you donated to someone else before this player will also get 10 cash and you will lose 20 - that's not what we want. We need to disconnect the old event.
The last code will therefore be:
local oldValue = nil local oldEvent = nil while wait() do -- wait() is just in case but should not be necessary as the repeat until will also yield here repeat wait() until plr.Value ~= oldValue -- plr.Value has changed -- if oldEvent then -- if there is an oldEvent we should disconnect it and replace it. oldEvent:disconnect() end --Define variables just in case (Resetting) local Cash = me.leaderstats.Cash --Leaderstats is the stat holder inside the player local OCash = plr.Value["leaderstats"].Cash --For the player that the points are going too. local Dbutton = FrameB.Page.DonateButton local Input = FrameB.Page.Input oldValue = Dbutton.Button1Down:connect(function() -- Put the event in a variable to disconnect later if Cash.Value <= tonumber(Input.Text) then Cash.Value = (Cash.Value - (tonumberInput.Text)) OCash.Value = (OCash.Value + (tonumberInput.Text)) end end) end