Need help to "Press E" Clone

  1. What do you want to achieve? We have a block after pressing “E” after 10 seconds it is deleted, and then we respawn again, and “Press E” appears again and so on in a cycle

  2. What is the issue? I have a block but no “Press e”

if workspace:FindFirstChild(Part) == nil then
					print("Me spawn you again")
					Part:Clone().Parent = workspace
					Part.ProximityPrompt.Triggered:Clone().Parent = Part
  1. What solutions have you tried so far? I found the answer to the block but not to “Press E”
local UserInputService = game:GetService("UserInputService")

-- define a function to handle the key press event
local function onKeyPress(input, gameProcessedEvent)
    if input.KeyCode == Enum.KeyCode.E then
        print("The 'E' key was pressed!")
    end
end

-- connect the function to the key press event
UserInputService.InputBegan:Connect(onKeyPress)
1 Like

Strange but it doesn’t print " The ‘E’ key was pressed!"

this is Local Script, what script did you use?

1 Like

Just a script not local maybe need use “nil”

This must be used in a local script

1 Like

You put Part.ProximityPrompt.Triggered:Clone(), .Triggered is an event when the player interacts with the prompt for the required time, and make it like this Part.ProximityPrompt:Clone().Parent = part

1 Like

I’m confused. is it like this?

local UserInputService = game:GetService("UserInputService")
local Part = script.Parent


Part.ProximityPrompt.Triggered:Clone(), .Triggere
local function onKeyPress(input, gameProcessedEvent)
	if input.KeyCode == Enum.KeyCode.E then
		print("The 'E' key was pressed!")
	end
end

	script.Parent.ProximityPrompt.Triggered:Connect(onKeyPress)
UserInputService.InputBegan:Connect(onKeyPress)

no, you only put the player variable for the arguments, like this

local Part = script.Parent

Part.ProximityPrompt.Triggered:Connect(function(player)
	print("The 'E' key was pressed!")
end)
1 Like
--like This?
local UserInputService = game:GetService("UserInputService")
local Part = script.Parent


Part.ProximityPrompt.Triggered:Connect(function(player)
	print("The 'E' key was pressed!")
end)
--Never worked with local scripts


script.Parent.ProximityPrompt.Triggered:Connect()
UserInputService.InputBegan:Connect()

This line means, when the proximityprompt (which is a child of Part) fires the event called “Triggered”, then do:
The triggered event returns a parameter(namely, the player who triggered it).
You could change the print to
print(player.Name … " triggered the ProximityPrompt.")

2 Likes

yes, exactly like this, but remove this part

script.Parent.ProximityPrompt.Triggered:Connect() UserInputService.InputBegan:Connect()
1 Like

Guys, a very simple solution (For Wii Lifehack) if you want to save the whole object with all the scripts, then just use this command
сopy original part

local Part = script.Parent
local UseE = Part.ProximityPrompt
local obj = Part:Clone()

script 
UseE.Triggered:Connect(function(player)

Part:Destroy()
wait(2)
obj.Parent = game.Workspace

all script (if you need)

local Part = script.Parent
local UseE = Part.ProximityPrompt
local Color = Part.BrickColor
local obj = Part:Clone()

UseE.Triggered:Connect(function(player)
	
	Part.BrickColor = BrickColor.new(122)
	wait(2)
	Part.BrickColor  = BrickColor.new(14)
	
	if Part.BrickColor == BrickColor.new(14) then
		Part:Destroy()
 		wait(2)
		obj.Parent = game.Workspace
	end
	
end)

{THIS IS VERY USEFUL FOR YOU, BELIEVE ME!
}

guys thx for help me its @VSCPlays @ExercitusMortem and @Agent_4004 THX SO MUCH!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.