I've been trying to make a door open and close, simple, yet I've only got a week's worth of experience with this coding thing, so I'd like some help.
My code works, but it only works for one player, I would like if the code would open the door for all players in the server, could anyone help me with this? here is what I currently have
print(game.Players.LocalPlayer)
local door = game.Workspace.Door.Door
local Player = game.Players.LocalPlayer
local NearDoor = false
local RunService = game:GetService("RunService")
local status = "closed"
RunService.RenderStepped:Connect (function()
if Player😀istanceFromCharacter(game.Workspace.Door.Door.Position) < 10 then
NearDoor = true
game.Workspace.Door.E.Enabled = true
else
NearDoor = false
game.Workspace.Door.E.Enabled = false
end
end)
game.Players.LocalPlayer:GetMouse().KeyDown:Connect(function(key)
if key == "e" and NearDoor == true and status == "open" then
door.Rotation = Vector3.new(0, 0, 0)
door.Position = Vector3.new(14.5, 6.5, 17.5)
status = "closed"
elseif key == "e" and NearDoor == true and status == "closed" then
door.Rotation = Vector3.new(0, 100, 0)
door.Position = Vector3.new(17.2, 6.5, 20)
status = "open"
end
end)
My code works, but it only works for one player, I would like if the code would open the door for all players in the server, could anyone help me with this? here is what I currently have
print(game.Players.LocalPlayer)
local door = game.Workspace.Door.Door
local Player = game.Players.LocalPlayer
local NearDoor = false
local RunService = game:GetService("RunService")
local status = "closed"
RunService.RenderStepped:Connect (function()
if Player😀istanceFromCharacter(game.Workspace.Door.Door.Position) < 10 then
NearDoor = true
game.Workspace.Door.E.Enabled = true
else
NearDoor = false
game.Workspace.Door.E.Enabled = false
end
end)
game.Players.LocalPlayer:GetMouse().KeyDown:Connect(function(key)
if key == "e" and NearDoor == true and status == "open" then
door.Rotation = Vector3.new(0, 0, 0)
door.Position = Vector3.new(14.5, 6.5, 17.5)
status = "closed"
elseif key == "e" and NearDoor == true and status == "closed" then
door.Rotation = Vector3.new(0, 100, 0)
door.Position = Vector3.new(17.2, 6.5, 20)
status = "open"
end
end)