I'm trying to make a press 'e' door when you get close enough but nothing happens when I touch part ( when you touch part and press e it opens the door ) But I can't get it to work please help
This is my client script
local player = game.Players.LocalPlayer
local part = script.Parent.Parent.uiAppear
local plr = game.Players.LocalPlayer
local ui = script.Parent.reeeeeeeeee
Base1 = script.Parent.Parent.Keycard1.Screen
Base2 = script.Parent.Parent.Keycard2.Screen
part.Touched:Connect(function(hit)
if plr.Character ~= nil and hit.Parent == plr.Character then
ui.Text.Visible = true
ui.Parent = player.PlayerGui
presse()
end
end)
function presse(plr)
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(key)
if key == Enum.KeyCode.E then
openDoor()
end
end)
end
function openDoor(plr)
local Find = player.Backpack:FindFirstChild("L"..script.Parent.Parent.Configuration.AccessLevel.Value.."-Keycard")
if Find then
script.Parent.OpenDoor:FireServer(Base1, Base2)
else
script.Parent.DontOpenDoor:FireServer(Base1, Base2)
end
end
This is My Server Script
local primary = script.Parent.Parent.Door
local TweenService = game:GetService("TweenService")
local TweenIn = TweenInfo.new(4, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local tweenclose = TweenService:Create(primary, TweenIn,{Position = Vector3.new(111.59, 6.16, 155.785)}) -- change to your positions
local tweenopen = TweenService:Create(primary, TweenIn, {Position = Vector3.new(118.25, 6.16, 155.785)})
--[[
script.Parent.Parent.Base.Touched:Connect(function(hit)
if hit.Parent.Name == "L1-Keycard" then -- Change TOOLNAMEHERE to your tool name
script.Parent.Parent.Screen.Color = Color3.new(1, 0, 0)
wait(1)
script.Parent.Parent.Screen.Color = Color3.new(1, 1, 1)
end
end)
script.Parent.Parent.Base.Touched:Connect(function(hit)
if hit.Parent.Name == "L2-Keycard" then -- Change TOOLNAMEHERE to your tool name
script.Parent.Parent.Screen.Color = Color3.new(1, 0, 0)
end
end)
script.Parent.Parent.Base.Touched:Connect(function(hit)
if hit.Parent.Name == "L3-Keycard" then -- Change TOOLNAMEHERE to your tool name
script.Parent.Parent.Screen.Color = Color3.new(0.431373, 1, 0)
tweenopen:Play()
print (1)
wait(5)
tweenclose:Play()
script.Parent.Parent.Screen.Color = Color3.new(1, 1, 1)
wait(2)
end
end)
script.Parent.Parent.Base.Touched:Connect(function(hit)
if hit.Parent.Name == "L4-Keycard" then -- Change TOOLNAMEHERE to your tool name
script.Parent.Parent.Screen.Color = Color3.new(0.431373, 1, 0)
tweenopen:Play()
print (1)
wait(5)
tweenclose:Play()
script.Parent.Parent.Screen.Color = Color3.new(1, 1, 1)
wait(2)
end
end)
script.Parent.Parent.Base.Touched:Connect(function(hit)
if hit.Parent.Name == "L5-Keycard" then -- Change TOOLNAMEHERE to your tool name
script.Parent.Parent.Screen.Color = Color3.new(0.431373, 1, 0)
tweenopen:Play()
print (1)
wait(5)
tweenclose:Play()
script.Parent.Parent.Screen.Color = Color3.new(1, 1, 1)
wait(2)
end
end)
]]
script.Parent.OpenDoor.OnServerEvent:Connect(function(Base1, Base2)
Base1.Color = Color3.fromRGB(76, 255, 0)
Base2.Color = Color3.fromRGB(76, 255, 0)
script.Parent.Swipe:Play()
tweenopen:Play()
wait(script.Parent.Parent.Configuration.DoorOpenTime)
tweenclose:Play()
end)
script.Parent.DontOpenDoor.OnServerEvent:Connect(function(Base1, Base2)
Base1.Color = Color3.fromRGB(255, 0, 4)
Base2.Color = Color3.fromRGB(255, 0, 4)
script.Parent.Swipe:Play()
end)

1 comment
Make the Touched Event On the Server.