Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago
Edited by EzraNehemiah_TF2 3 years ago
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)
0
code block, use the touched event Pupppy44 671 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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)
Ad

Answer this question