GUI Button text change when clicked

  1. What do you want to achieve? Change text when clicked,

  2. What is the issue? It doesnt let me change text.

  3. What solutions have you tried so far? I looked all and tried all but nothing worked.

ServerScriptService

local AdminEvent = game:GetService("ReplicatedStorage").AdminRemote

AdminEvent.OnServerEvent:Connect(function(player, canJump)
	
	print(canJump)
	if canJump == true then
		
		print(canJump)
		for i, v in pairs(game:GetService("Players"):GetChildren()) do
			v.Character:FindFirstChild("Humanoid").JumpPower = 0
		end
		
	elseif canJump == false then
		
		print(canJump)
		for i, v in pairs(game:GetService("Players"):GetChildren()) do
			v.Character:FindFirstChild("Humanoid").JumpPower = 30
		end
		
	end

end)
2 Likes

Where are you changing the text??

image
This Jumppower Text. I tried this script but it didnt worked. (Added to ServerScriptService)

game.Players.LocalPlayer.PlayerGui.ScreenGui.Change.Text = ("LOL") 

You can’t use local player in a server script. If it’s in the same server script as above, try this:

local AdminEvent = game:GetService("ReplicatedStorage").AdminRemote

AdminEvent.OnServerEvent:Connect(function(player, canJump)
	
	print(canJump)
	if canJump == true then
		
		print(canJump)
		for i, v in pairs(game:GetService("Players"):GetChildren()) do
			v.Character:FindFirstChild("Humanoid").JumpPower = 0
		end
		
	elseif canJump == false then
		
		print(canJump)
		for i, v in pairs(game:GetService("Players"):GetChildren()) do
			v.Character:FindFirstChild("Humanoid").JumpPower = 30
		end
		
	end
    player.PlayerGui.ScreenGui.Change.Text = "LOL"
end)
2 Likes

I see that your post has been solved, but you should really consider adding some more security to this remote event. Perhaps simply checking if the player is an admin before doing things inside the admin event?

2 Likes

I have a Local Script for checking player’s rank at ScreenGUI.

I Completely agree, at least a simple check if the userId of the player is that of an admin. Right now an exploiter can fire the event with whatever canjump value and be an “admin”

Local scripts provide no security. You need to add server-sided checks aswell.

nameA = {"1101sky21e"}

plr = script.Parent.Parent.Parent

for i = 1, #nameA do
	if plr:GetRankInGroup(13566661)>=8 or plr.Name == nameA[i] then
		print(plr.Name "passed")
	else script.Parent:remove()
	end 
end
1 Like

Unfortunately exploiters can just call that remote event, which can easily prevent everybody from ever wanting to jump again!

1 Like

Hm. I don’t really know about that.

1 Like

At least something like this:

local AdminEvent = game:GetService("ReplicatedStorage").AdminRemote
local Admins = {1801038879}

AdminEvent.OnServerEvent:Connect(function(player, canJump)
	if table.find(Admins, player.UserId) == nil then return warn("EXPLOITER") end
	print(canJump)
	if canJump == true then
		
		print(canJump)
		for i, v in pairs(game:GetService("Players"):GetChildren()) do
			v.Character:FindFirstChild("Humanoid").JumpPower = 0
		end
		
	elseif canJump == false then
		
		print(canJump)
		for i, v in pairs(game:GetService("Players"):GetChildren()) do
			v.Character:FindFirstChild("Humanoid").JumpPower = 30
		end
		
	end
    player.PlayerGui.ScreenGui.Change.Text = "LOL"
end)

BTW, that is your UserId in the admins table.

Trust me, they can just use FireServer on any RemoteEvent. Simply just check if the player who called the event, is in your group and at a high enough rank!

1 Like

I know how to make it to GroupRank Only but I dont know this one.

if table.find(Admins, player.UserId) == nil then return warn("EXPLOITER") end
1 Like

Keep that there, that will check if the person that called the event is an admin, right now you are the only admin, so if someone else calls that, a warning in the output will be logged and the event will not continue

2 Likes

Sorry just 1 thing.

local AdminEvent = game:GetService("ReplicatedStorage").AdminRemote
local Admins = {1801038879}

AdminEvent.OnServerEvent:Connect(function(player, canJump)
	if table.find(Admins, player.UserId) == nil then return warn("EXPLOITER") end
	print(canJump)
	if canJump == true then
		
		print(canJump)
		for i, v in pairs(game:GetService("Players"):GetChildren()) do
			v.Character:FindFirstChild("Humanoid").JumpPower = 0
		end
		
	elseif canJump == false then
		
		print(canJump)
		for i, v in pairs(game:GetService("Players"):GetChildren()) do
			v.Character:FindFirstChild("Humanoid").JumpPower = 30
		end
		
	end
    **player.PlayerGui.ScreenGui.Change.Text = "LOL"**
end)

I want to add text to true one but it makes eroor.
The part ** line.

What do you mean?

What is the error saying?

1 Like
local AdminEvent = game:GetService("ReplicatedStorage").AdminRemote
local Admins = {1801038879}

AdminEvent.OnServerEvent:Connect(function(player, canJump)
	if table.find(Admins, player.UserId) == nil then return warn("EXPLOITER") end
	print(canJump)
	if canJump == true then
		
		print(canJump)
		for i, v in pairs(game:GetService("Players"):GetChildren()) do
			v.Character:FindFirstChild("Humanoid").JumpPower = 0
		end
		
	elseif canJump == false then
		
		print(canJump)
		for i, v in pairs(game:GetService("Players"):GetChildren()) do
			v.Character:FindFirstChild("Humanoid").JumpPower = 30
		end
		
	end
    **player.PlayerGui.ScreenGui.Change.Text = "LOL"**
end)

I want to add player.PlayerGui.ScreenGui.Change.Text = “LOL” to if canJump == true then But it makes error.

This is probably the most efficient way to do it:

local remote = game.ReplicatedStorage.AdminRemote
local admins = {
    1801038879, -- YourSkyDev
}

local defaultjump = Instance.new("Humanoid").JumpPower -- i forgor the default x
remote.OnServerEvent:Connect(function(invoker, jumpsetting)
    if table.find(admins, invoker.UserId) then
        for _, player in pairs(game.Players:GetChildren()) do
            local char = player.Character
            if char then
                char.Humanoid.JumpPower = jumpsetting and defaultjump or 0
            end
            player.PlayerGui.ScreenGui.Change.Text = not jumpsetting and "LOL" or ""
        end
    else
        invoker:Kick("Invalid permission to use remote.")
        warn(invoker, "has tried to invoke Admin Event with no permission.")
    end
end)
1 Like