Script Help! Enable GUI by Points

Making a script that only allows you to wear clothes (via GUI button) if you have enough points. If you don’t have enough points another GUI will pop up saying you don’t have enough points.
But the GUI won’t pop up during the function.

I’m new to scripting and I have no clue what I’m doing. I’ve tried a few things over the past couple days, so I decided to come here for help.

local Event = Instance.new("RemoteEvent")
Event.Parent = game.ReplicatedStorage
Event.Name = "UniformGiveEventWR"
local Shirt = "rbxassetid://0"
local Pants = "rbxassetid://6487745112"
local GUI = game.StarterGui.Leotards.TFrame.NEP

function GiveUni(plr)
	if plr.leaderstats.Points.Value < 4000 then
		GUI.Visible = true
		wait(3)
		GUI.Visible = false
		if plr.leaderstats.Points.Value >= 4000 then
			GUI.Visible = false
		end
	local character = plr.Character
	local shirt = character.Shirt
	local pants = character.Pants
	shirt.ShirtTemplate = Shirt
	pants.PantsTemplate = Pants
end

Event.OnServerEvent:Connect(GiveUni)
1 Like

You can use a HumanoidDescription to change the players clothing. Also, do not index the GUI using StarterGui, this is only cloned to the players PlayerGui when the player joins the game, and I’m pretty sure when they die.

function GiveUni(plr)
    local GUI = plr.PlayerGui.Leotards.TFrame.NEP
	if plr.leaderstats.Points.Value < 4000 then
		GUI.Visible = true
		wait(3)
		GUI.Visible = false
		if plr.leaderstats.Points.Value >= 4000 then
			GUI.Visible = false
		end
	local character = plr.Character
	local shirt = character.Shirt
	local pants = character.Pants
	shirt.ShirtTemplate = Shirt
	pants.PantsTemplate = Pants
end

Event.OnServerEvent:Connect(GiveUni)

Just replace the GiveUni Function with this.

Ok, so now the GUI will pop up the first time I click the button, but anytime I click after that the script will not run. What should I do now?

local Event = Instance.new("RemoteEvent")
Event.Parent = game.ReplicatedStorage
Event.Name = "UniformGiveEventWR"
local Shirt = "rbxassetid://0"
local Pants = "rbxassetid://6487745112"

function GiveUni(plr)
	local GUI = plr.PlayerGui.Leotards.TFrame.NEP
	if plr.leaderstats.Points.Value < 4000 then
		GUI.Visible = true
		wait(3) 
		GUI.Visible = false
		if plr.leaderstats.Points.Value >= 4000 then
			GUI.Visible = false
			local character = plr.Character
			local shirt = character.Shirt
			local pants = character.Pants
			shirt.ShirtTemplate = Shirt
			pants.PantsTemplate = Pants
		end
	end
end

Event.OnServerEvent:Connect(GiveUni)

You put the second if statement inside your other one, you should be doing elseif to fix that hopefully

local Event = Instance.new("RemoteEvent")
Event.Parent = game.ReplicatedStorage
Event.Name = "UniformGiveEventWR"
local Shirt = "rbxassetid://0"
local Pants = "rbxassetid://6487745112"

function GiveUni(plr)
	local GUI = plr.PlayerGui.Leotards.TFrame.NEP
	if plr.leaderstats.Points.Value < 4000 then
		GUI.Visible = true
		wait(3) 
		GUI.Visible = false
	elseif plr.leaderstats.Points.Value >= 4000 then
		GUI.Visible = false
		local character = plr.Character
		local shirt = character.Shirt
		local pants = character.Pants
		shirt.ShirtTemplate = Shirt
		pants.PantsTemplate = Pants
	end
end

Event.OnServerEvent:Connect(GiveUni)
1 Like

The GUI will only pop up the first time I click the button. Not sure why this is happening.

1 Like

You’re probably only firing the event once from the client side for some reason, the server side script seems to work fine unless if it’s where you’ve made the Event

1 Like

I’m new to scriting so that doesn’t make sense to me :sweat_smile: so how do I make it a server side script?

You could just show the client script that Fires that certain RemoteEvent, you don’t need to make it entirely server-sided :thinking:

1 Like

Not sure what that means but this is the event?

local button = script.Parent.Parent.ScrollingFrameW.RedLeo
local debounce = true
local UniEvent = game.ReplicatedStorage:WaitForChild("UniformGiveEventWR")

button.MouseButton1Click:Connect(function()
	if debounce then
		debounce = false
		UniEvent:FireServer()
	end
end)
1 Like

Yeah you did what I needed lol

This if statement right here is checking if the debounce is true or not, if it is then you’re firing the Event and setting the debounce to false but you’re not changing it back to true after a certain interval of time, you’re just leaving it as that which is only firing once

1 Like

Ok, I see what you’re saying lol thank you so much for being patient with me! It worked!

2 Likes

It’s completely fine everyone struggles :sweat_smile: No matter how simple or complicated the issue could be, glad I was able to help though!

2 Likes