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

How do I make it impossible to open the gui with "e" when player is not on "PressurePlate"?

Asked by 4 years ago
Edited by Leamir 4 years ago

This is the script that makes the player being able to open a gui, it is on a part that the player must stand on:

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)

This is the script that makes it possible to open a/the gui with "e":

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
            script.Parent.Visible = true
        end
    end)
end)
0
make it so you have to be on the pressure plate to press e put them together into 1 script DuckyRobIox 280 — 4y
0
How do I put them together into 1 script, please explain further? VelocityVH 6 — 4y

Answer this question