local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local Part = game.workspace.Pinkegg --Defining the Part
print("Code online")
local function RemoveTool(Hit) --Creating the local function, which "Hit" is the first parameter for the "Touched" event
print("Part touched")
local Check = game.Players:GetPlayerFromCharacter(Hit.Parent) --Getting the Player from the Character Model
if Check then --Checking if we have a player
print("Enabling the GUI for: "..Player.Name)
PlayerGui.PinkeggGet.Frame.Visible = true
wait(.5)
Part:Destroy()
end
end
Part.Touched:Connect(RemoveTool)
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Gui = Player.PlayerGui:WaitForChild("PinkeggGet")
local Part = workspace:WaitForChild("Pinkegg")
local function ResearchCrate(Hit)
Gui.Frame.Visible = true
print("Gui Enabled")
wait()
Part:Destroy()
Part = nil
end
Part.Touched:Connect(ResearchCrate)
Add a debounce like this:
This occurred to my in my typewriter script, debounce fixed it.
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Gui = Player.PlayerGui:WaitForChild("PinkeggGet")
local Part = workspace:WaitForChild("Pinkegg")
local db = false
local function ResearchCrate(Hit)
if not db then
db = true
Gui.Frame.Visible = true
print("Gui Enabled")
wait()
Part:Destroy()
Part = nil
end
end
Part.Touched:Connect(ResearchCrate)
So I did a lot of just retyping the script, and deleting it and remaking it, and it finally worked, but only on roblox studio. The server side on studio doesnât show the egg being deleted or the GUI showing, so I published the game and tested it on 2 different accounts, but it doesnât work there. (I made one account touch the part, and the other stand there and it showed the GUI showing and the Part deleted on both accounts, In game.)