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)
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)
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)
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
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)
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