Problem with GUI spawn [SOLVED]

Well, this is a problem.

So basically, I am trying to make a script which removes all the items from the player’s inventory using a ProximityPrompt through a LocalScript (because I want a TextLabel to show up saying which item you removed). My code goes like this:

local descendants = game:GetDescendants()

for _, descendant in pairs(descendants) do
	if descendant:IsA("ProximityPrompt") and descendant.Name == "trashPrompt" then
		print("foundPrompt")
		descendant.Triggered:Connect(function()
			local tools = player.Backpack:FindFirstChildOfClass("Tool") or player.Character:FindFirstChildOfClass("Tool")
			if not tools then
				player.Character.ChildAdded:Wait()
				player.Backpack.ChildAdded:Wait()
			end
			if tools:IsA("Tool") or tools:IsA("HopperBin") then
				tools:Destroy()
				tweenWarning("Removed"..tools.Name)
			else
				print("there's no tool to clear")
			end
		end)
	end
end

The problem with THIS is that it completes the function properly, but the TextLabel doesn’t show up at ALL. (I also tried using Instance.new and TweenPosition, had the same result)

Would appreciate help ASAP. Thanks!

1 Like

can you show your script for the tweenWarning function and the text label?

you are trying to take the ‘tools.Name’ after you destroyed it.

maybe try tweenWarning first before destroying it?

Move the tween warning function above the line where you destroyed that tool.

local function tweenWarning(text)
	local clone = warning:Clone()
	clone.Text = text
	clone:TweenPosition(UDim2.new(0.5,0,0.8,0),"Out","Quint",0.2)
	wait(1)
	clone:TweenPosition(UDim2.new(0.5,0,1,0),"In","Back",0.2)
end

The main problem is that an error shows up: Can only tween objects in the workspace

@vyexon and @666demonical999 that option doesn’t work, still does the same thing. I checked the Visible and it was set to true; TextTransparency was also set to 0

Oh, my bad. I tried the same idea, it still prints out the part name even though its desroyed. guess im still learning things.

try setting the cloned parent to Player:WaitForChild("PlayerGui")

and if it is, try doing:

local TweenService = game:GetService("TweenService")

local Tween1 = TweenInfo.new(0.2, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
local Tween2 = TweenInfo.new(0.2, Enum.EasingStyle.Back, Enum.EasingDirection.In)

local function tweenWarning(text)
	local clone = warning:Clone()
	clone.Text = text
	TweenService:Create(clone, Tween1, {Position = UDim2.new(0.5, 0, 0.8, 0)}):Play()
    wait(1)
    TweenService:Create(clone, Tween2, {Position = UDim2.new(0.5, 0, 0.1, 0)}):Play()
end

my code is messy but I hope this fixes the problem.

Somehow, even with all your work, still hasn’t changed ANYTHING.

maybe there’s something wrong with my studio lol

can you show the declaration of “warning”?

Don’t really understand what you mean by that.

i think i’ve came across a problem like this before, a simple task.wait() after the “clone” variable will maybe fix it

can you show where the variable with name of “warning” is?

Didn’t work. Sorry for wasting your time with this lol

image

The LocalScript named LocalScript is where I run the command (I shifted it away from the mainScript thinking that it would work)

nah its okay ill try my best to help ya out

well are you 100% sure that ProximityPrompt.Triggered gets fired in the script?

Yep, it runs the print() command and everything. It’s just that the GUI doesn’t show up.

well maybe Try TweenService instead of the built-in function “TweenPosition”

Already tried @666demonical999’s answer. Doesn’t change a thing.