Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why can't i change stat value?

Hi! So I was making a admin panel for my game, and I had a problem recently.

I'm planning to make it when you clicked the button it will detect what stat you want and it will change that stat for you but it didn't work, I checked output and there is no errors.

Problem: The stat value didn't change but it will print("Clicked!") when mouse button 1 is clicked

This is the script code:

local plr = script.Parent.Parent.Parent
local Button = script.Parent.Panel.Buttons.Cash
local arg1 = Button.Textbox1.Text

Button.MouseButton1Click:Connect(function()
	print("Clicked!")
	if arg1 == "Cash" then
		plr.Stats.Cash.Value = Button.Value.Value
		print("Works")
	elseif arg1 == "Multiplier" then
		plr.Stats.Multiplier.Value = Button.Value.Value
		print("Works")
	elseif arg1 == "Rebirth" then
		plr.Stats.Rebirth.Value = Button.Value.Value
		print("Works")
	elseif arg1 == "UltraRebirth" then
		plr.Stats.UltraRebirth.Value = Button.Value.Value
		print("Works")
	elseif arg1 == "Prestige" then
		plr.Stats.Prestige.Value = Button.Value.Value
		print("Works")
	elseif arg1 == "SuperPrestige" then
		plr.Stats.SuperPrestige.Value = Button.Value.Value
		print("Works")
	elseif arg1 == "HyperPrestige" then
		plr.Stats.HyperPrestige.Value = Button.Value.Value
		print("Works")
	elseif arg1 == "UltraPrestige" then
		plr.Stats.UltraPrestige.Value = Button.Value.Value
		print("Works")
	elseif arg1 == "OmgegaPrestige" then
		plr.Stats.OmegaPrestige.Value = Button.Value.Value
		print("Works")
	elseif arg1 == "Sacrifice" then
		plr.Stats.Sacrifice.Value = Button.Value.Value
		print("Works")
	elseif arg1 == "HugeSacrifice" then
		plr.Stats.HugeSacrifice.Value = Button.Value.Value
		print("Works")
	elseif arg1 == "ULT" then
		plr.Stats.ULT.Value = Button.Value.Value
		print("Works")
	end
end)

If you can help me with this problem, thanks alot!

1 answer

✓ Accepted answer

You need to use a server script due to FE (filtering enabled)

Local script:

local plr = script.Parent.Parent.Parent
local Button = script.Parent.Panel.Buttons.Cash
local arg1 = Button.Textbox1.Text

Button.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Adminpanel:FireServer(Button.Name,{['Arg1']=arg1,['Arg2']=Button})
end)

Server script:

local Admins={ -- name of admins
'chiazk'
}
function CheckIsAdmin(Player)
for _,Admin in pairs(Admins) do
if(Player.Name==Admin)or(Player.UserId==Admin)then
return true
end
end
return false
end
game.ReplicatedStorage.Adminpanel.OnServerEvent:Connect(function(Player,Type,Args)
if(CheckIsAdmin(Player))then
if(Type=='Cash')then
for _,Stat in pairs(Player.Stats:children()) do
if(Stat.Name:lower()==Args['Arg1']:lower())then
Stat.Value=Args['Args2'].Value.Value
end
end
end
else
-- Not a admin maybe kick?
Player:Kick('You are not a admin ...')
end
end)

2 comments

0

Special thanks to you for helping me to solve this issue!

0

np

This discussion is preserved as it was. New answers, comments, and votes are closed.