(LocalScript in GUI)
local inputservice = game:GetService("UserInputService")
inputservice.InputBegan:connect(function(i,g)
if i.UserInputType == Enum.UserInputType.Keyboard then
if i.KeyCode == Enum.KeyCode.E then
for _,Door in pairs(workspace.Doors:GetChildren()) do
Door.Event:FireServer()
break
end
end
end
end)
while wait() do
script.Parent.ImageLabel.Visible = false
for i,v in pairs(game.Workspace.Doors:GetChildren()) do
local mag = (v.Center.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude
if mag <= 10 then
local WSP = game.Workspace.CurrentCamera:WorldToScreenPoint(v.Center.Position)
script.Parent.ImageLabel.Visible = true
script.Parent.ImageLabel.Position = UDim2.new(0,WSP.X,0,WSP.Y)
end
end
end
Server script in door
local Can = true
local Open = false
script.Parent.Event.OnServerEvent:connect(function(Player)
local Mag = (script.Parent.Center.Position-Player.Character.HumanoidRootPart.Position).magnitude
if Mag <= script.Parent.Range.Value then
if Can then
Can = false
if Open == false then
local finish = script.Parent.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0)
for i = 0,1,.1 do
local cfm = script.Parent.PrimaryPart.CFrame:lerp(finish,i)
script.Parent:SetPrimaryPartCFrame(cfm)
wait()
end
Open = true
else
Open = false
local finish = script.Parent.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0)
for i = 0,1,.1 do
local cfm = script.Parent.PrimaryPart.CFrame:lerp(finish,i)
script.Parent:SetPrimaryPartCFrame(cfm)
wait()
end
end
Can = true
end
end
end)
For some reason multiple doors won’t work with this…? I am completely stumped, anybody know why?