Help with script - When player touches a part a gui appears

Ok so you can use then

local debounce = true

game.Workspace.PartToTouch.Touched:Connect(function(hit)
   if game.Players.GetPlayerFromCharacter(hit.Parent) and debounce then
      script.Parent.Frame.Visible = true
      debounce = false
   end
end)
1 Like

Ok and in the script section do I put the script that runs my typewriting in the gui?

Here is the complete code without RemoteEvents if you are interested.

local Part = "Path to part"
local Gui = "Path to gui" 
local Bool = "Path to boolValue" 

Part.Touched:Connect(function(_Hit)
if _Hit.Parent then
    if not Bool then
        Bool = true
            GUI.Visible = true
        end
    end
end)

If itā€™s a local script, it can go anywhere in StarterGui or StarterPlayerScripts.

Thatā€™s basically my code in different variables

Sorry i am on phone and i canā€™t see any new replies while making one.

local Frame = script.Parent.Frame
local debounce = true

local function typeWriting(typeWriteFrame)
	
	-- Do the typewriting stuff, if you need more help on that im always online!
	
end

game.Workspace.PartToTouch.Touched:Connect(function(hit)
   if game.Players.GetPlayerFromCharacter(hit.Parent) and debounce then
     Frame.Visible = true
     
     typeWriting(Frame)

     debounce = false
   end
end)

Thatā€™s the end script Kinda

im using the typeWriting(typeWriteFrame)

so anywhere in the function you can just say frame.Text or something like that

You should probably check for the Humanoid first or it may error.

this is the gui that contains the typewriting
image
so where do I put that script?

itā€™s okay the

game.Players.GetPlayerFromCharacter(hit.Parent)

Checks if the entity that touched the part is player

I mean like the part where it says --script, I donā€™t know what to put there.

Put the updated version i sent u in the same script

ok so where do i put this script? In the local script that is in whereā€¦?
the main script
this one

local Frame = script.Parent.Frame
local debounce = true

local function typeWriting(typeWriteFrame)

-- Do the typewriting stuff, if you need more help on that im always online!

end

game.Workspace.PartToTouch.Touched:Connect(function(hit)
if game.Players.GetPlayerFromCharacter(hit.Parent) and debounce then
Frame.Visible = true

 typeWriting(Frame)

 debounce = false

end
end)

1 Like

Not that, before that, like the whole script but it has typeWriting in it

That 1 line is me explaining to @Tr0_p that it already has some player checks, you donā€™t have to worry about it

Yes that one

30 charsā€¦

Ok ok I am currently confused once again lol. @iFlameyz, I have chosen to use your idea then I will see how it goes. How do I start?

Haha okay, so Find your frame that you want to activate when a player stands on it, put a local script in the Frame and write this inside it:

local Frame = script.Parent
local debounce = true

local function typeWriting(typeWriteFrame)
	
	-- Do the typewriting stuff, if you need more help on that im always online!
	
end

game.Workspace.PartToTouch.Touched:Connect(function(hit)
   if game.Players.GetPlayerFromCharacter(hit.Parent) and debounce then
     Frame.Visible = true
     
     typeWriting(Frame)

     debounce = false
   end
end)

Btw i edited:
local Frame = script.Parent.Frame
to
local Frame = script.Parent

Ok so where it says do the typewriting stuff, thatā€™s where I put the typewriting script with all the text that I want it to type?

Yeah thatā€™s correct, but make sure to put any textLabel inside the frame so it works like

local function typeWriting(typeWriteFrame)
	
	-- Do the typewriting stuff, if you need more help on that im always online!
	
   typeWriteFrame.TextLabel.Text -- That's an example

end

If youā€™re confused where to put the text, put it in the same file where the local script is, NOT inside the local script but in the same place