Hello, all!
I’ve caught myself in a really weird situation.
My game has a rainy environment which we’re introducing as part of a fun event, temporarily.
The rain script duplicates its assets into the player’s PlayerGui - I found this by testing in studio and in-game using Adonis’ Dex function.
I wrote a localscript due to feedback regarding loss of performance due to the rain.
It’s contained within a text button, as part of the LocalPlayer’s PlayerGui.
The script literally ceases to function, but I have no errors. None in my code, none in my local output, none anywhere.
It just doesn’t work.
Am I doing something wrong?
For reference:
Take script.Parent
to be a TextButton.
Take Items to contain names of things stored in the LocalPlayer’s PlayerGui.
Take StarterGui as a place that contains all the elements I can recover for the user.
Code:
local Items = {"Rain", "RainyDay", "SoundPlayer", "SplashRenderer", "Splash", "DropSurface", "DropleSurface", "Raindrop"}
local Player = game:GetService("Players").LocalPlayer
local PGui = Player:WaitForChild("PlayerGui")
script.Parent.MouseButton1Click:Connect(function()
for i,a in pairs(PGui:GetChildren()) do
if Items[a.Name] then
a:Destroy()
else
for i,v in pairs(game.StarterGui:GetChildren()) do
if Items[v.Name] then
v:Clone().Parent = PGui
end
end
end
end
end)
Any help or suggestions are appreciated. Thank you!