Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What can I put in the blank space to see if the part "PressurePlate" is touched by player?

local Plr = game.Players.LocalPlayer
local PressurePlate = game.Workspace.SharesMachine.PressurePlate

Plr:GetMouse().KeyDown:Connect(function(K)
	if K == "e" then
		if ________ then
			script.Parent.Visible = true
		else
			script.Parent.Visible = false
		end
	end
end)

2 comments

0

code block, use the touched event

1 answer

✓ Accepted answer

You would actually need to use a ServerScript as well in that. Here is my recommendation:

Setup (everything is very important):

Place this ServerScript inside the Pressure plate:

local PressurePlate = script.Parent
local Remote = Instance.new('RemoteEvent', game.ReplicatedStorage)
Remote.Name = "PadPressed"

PressurePlate.Touched:Connect(function(hit)
	if game.Players:GetPlayerFromCharacter(hit.Parent) then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		Remote:FireClient(plr)
	end
end)

Place this in a LocalScript that is the child of StarterGui:

local Remote = game.ReplicatedStorage:WaitForChild("PadPressed")
local plr = game.Players.LocalPlayer

Remote.OnClientEvent:Connect(function()
	plr:GetMouse().KeyDown:Connect(function(K) 
		if K == "e" then
			--finish your event here
		end
	end)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.