Script Problems

  1. I try to make a part and when you touch it, a ScreenGui appears

  2. The problem is that I had developed this thing in a test place, then I put it in my game, it didn’t work And I hadn’t touched anything (and it’s not the first time its happens to me)

    image

here is the script :

image

  1. I didn’t found something on the DevForum

Can Someone help me please !

1 Like

image
Change it to script.ScreenGui.

i would try to change
Popup = script.Parent.ScreenGui to Popup = script.ScreenGui

It Still doesn’t work, by the way in the test place, the script is working with “Popup = script.Parent.ScreenGui”

But is it possible that the script does not work because there is already a lot of script in my game and there are a lot of parts?

You should be handling your script on the client (I mean, you don’t have to, but I suggest you to)… I’ve created a new script for you. Create a LocalScript and change it to this:

LocalScript
local Popup = script:WaitForChild("ScreenGui") -- your popup gui
local PartToTouch = game.Workspace.TestPart -- choose your part
local Player = game:GetService("Players").LocalPlayer
local Ready = true

local function onTouch(hit)
	if hit.Parent:IsA("Model") then
		local hitPlr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
		if hitPlr and hitPlr == Player then
			if Ready then
				Ready = false
				local PlayerGui = Player:WaitForChild("PlayerGui")
				local PopupClone = Popup:Clone()
                PopupClone.Enabled = true
				PopupClone.Parent = PlayerGui
				task.wait(1)
				Ready = true
			end
		end
	end
end

PartToTouch.Touched:Connect(onTouch)

Make sure to reference the part you want touched, in the LocalScript. Also, make sure to parent/place your ScreenGui into the LocalScript, and parent/place the LocalScript into StarterPlayer > StarterPlayerScripts

In your future projects, make sure to use task.wait instead of wait.

1 Like

Let me remake the code for you.
Please mark this as the :white_check_mark:Solution if this helped.

local Popup = script.ScreenGui
local Ready = true

local function onTouch(hit)
local humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")

     if humanoid and Ready == true then
          Ready = false
          local player = game.Players:GetPlayerFromCharacter(hit.Parent)
          local c = Popup:Clone()
          c.Parent = player.PlayerGui
          wait(1)
          Ready = true
    end
end

script.Parent.Touched:Connect(onTouch)

You had a lot of errors in your code.
Note: Always put local in front of a variable. So hackers can’t access it easily.

local Popup = script.Parent.ScreenGui → local Popup = script.ScreenGui

maybe the screen gui is disabled

local Players = game:GetService("Players")
local Popup = script:WaitForChild("ScreenGui")
local debounce = true

function onTouch(Hit)
	local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
	if Humanoid and debounce then
		debounce = not debounce

		local Player = Players:GetPlayerFromCharacter(Humanoid.Parent)
		if not Player then return end

		local Clone = Popup:Clone()
		Clone.Enabled = true
		Clone.Parent = Player.PlayerGui

		task.wait(1)

		debounce = not debounce
	end
end
script.Parent.Touched:Connect(onTouch)

All the script doesn’t work ): (by the way i change the script to a localscript ), in the OutPut there isn’t error too, thanks for helping everybody.

But is it possible that the script does not work because there is already a lot of script in my game and there are a lot of parts?

1 Like

Add a Script in the part and copy the code that I sent you.

It’s working ! Thanks you everyone To help me

Have nice day !

1 Like

Please note my code as the solution!