hey there, i have turned to scripting helpers NOT for a request but a start/Explanantion on why my script will NOT delete my gui?
i have an on touched event triggered when a player touches the part but the gui will not remove itself after a said amount of time, its frustrating because i also cannot find any help on google, they only help with touched event with a gui you manually close with Mouse Click, i'll explain a little more...
my part is in the workspace spawned in via debris, then when a player touches it, it counts as a point toward money, which works perfectly in server and client mode. but i want there to be a gui popup that says "you picked up...." simply because the player doesnt need to press F like they need to for my NPCs, so they wont exactly know they picked up anything. my GUI appears on screen when touched, but i can't find a way to DELETE it or make it INVISIBLE after say... 3 seconds.
i have tried to have the gui deleted after 3 seconds but when i enter the game it deletes in all my debris after 3 seconds before i pick it up, my issue being i really cant find a local player, to delete it so it deletes itself after 3 seconds in the Debris, instead of player GUI, i feel dumb like this is very easy but i am missing something. is this a local script?
any help would be appreciated.
EDIT: this is the code: sorry if it is a mess lol i am a little lost
local Part = script.Parent local DBounce = true Part.Touched:connect(function(hit) if hit and hit.Parent:FindFirstChild("Humanoid") and DBounce then DBounce = false local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player.PlayerGui:FindFirstChild("Notice") then player.PlayerGui.Notice.TextLabel.Visible = true wait(3) player.PlayerGui.Notice.TextLabel.Visible = false end wait() DBounce = true end end)
Okay, just to start off, if this is a server script, they can't go into a player's GUI. So make sure this is a local script! Also, game.Players:GetPlayerFromCharacter is useful, but pops up errors sometimes saying it's a nil value (it works both ways, but the errors would create some issues later on with lag). Other than that, this code should work. (Note, :connect is deprecated. Best to use :Connect instead)
--Make sure it's a local script! local Part = game.Workspace.InsertThePartNameHere --Insert part name local DBounce = true Part.Touched:Connect(function(hit) -- Use :Connect. It's lowercase form is deprecated! if hit and hit.Parent:FindFirstChild("Humanoid") and DBounce then DBounce = false if hit.Parent == game.Players.LocalPlayer.Character then --To avoid errors. script.Parent.TextLabel.Visible = true --Changed it for local script wait(3) --I want you to figure out where this goes. script.Parent.TextLabel.Visible = false --Hint(it's the textlabel's parent or GUI) end wait() DBounce = true end end)