local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local mouse = localPlayer:GetMouse()
local DoorPart = workspace.Build.DoorPart
local DoorValue = workspace.Build.Door.DoorDestroyValue
script.Parent = localPlayer.Backpack:WaitForChild("MasterKey")
mouse.Button1Down:Connect(function()
if mouse.Target == DoorPart then
print("Mouse")
DoorValue.Value = true
end
end)
→ Create RemoteEvent on replicated storage
→ Name it “Deletedoor” or something
→ create a script in ServerScriptService
Server Script :
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DeletedoorRemote = ReplicatedStorage:WaitForChild("Deletedoor")
function OnDoorValueChanged(DoorModel)
if DoorModel.doorDestroyValue.Value == true then
print("Value is true")
else
print("Value is false")
end
end
for i,v in pairs(workspace.Build:GetChildren()) do
if v.Name == "Door" then
v.doorDestroyValue:GetPropertyChangedSignal("Value"):Connect(function()
task.wait()
OnDoorValueChanged(v)
end)
end
end
DeletedoorRemote.OnServerEvent:Connect(function(Player,DoorModel)
if not DoorModel:FindFirstChild("DoorDestroyValue") then
warn("DoorDestroyValue is missing from DoorPart")
return
end
DoorModel.DoorDestroyValue.Value = true
end)
LocalScript :
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DeletedoorRemote = ReplicatedStorage:WaitForChild("Deletedoor")
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local mouse = localPlayer:GetMouse()
script.Parent = localPlayer.Backpack:WaitForChild("MasterKey")
mouse.Button1Down:Connect(function()
if mouse.Target and mouse.Target.Name == "DoorPart" then
print("Mouse")
DeletedoorRemote:FireServer(mouse.Target)
end
end)
oh it seems like i made a typo in the previous server script try this one
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DeletedoorRemote = ReplicatedStorage:WaitForChild("Deletedoor")
function OnDoorValueChanged(DoorModel)
if DoorModel.DoorDestroyValue.Value == true then
print("Value is true")
else
print("Value is false")
end
end
for i,v in pairs(workspace.Build:GetChildren()) do
if v.Name == "Door" then
v.DoorDestroyValue:GetPropertyChangedSignal("Value"):Connect(function()
task.wait()
OnDoorValueChanged(v)
end)
end
end
DeletedoorRemote.OnServerEvent:Connect(function(Player,DoorModel)
if not DoorModel:FindFirstChild("DoorDestroyValue") then
warn("DoorDestroyValue is missing from DoorPart")
return
end
DoorModel.DoorDestroyValue.Value = true
end)
inside door model (the one thats in the builds folder) you could create part named “DoorPart” and update localscript to this
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DeletedoorRemote = ReplicatedStorage:WaitForChild("Deletedoor")
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local mouse = localPlayer:GetMouse()
script.Parent = localPlayer.Backpack:WaitForChild("MasterKey")
mouse.Button1Down:Connect(function()
if mouse.Target then
if mouse.Target.Name == "DoorPart" and mouse.Target.Parent.Name == "Door" then
print("Mouse")
DeletedoorRemote:FireServer(mouse.Target)
end
end
end)
It looks like you forgot to make part named “DoorPart” inside the door model i also made some typos in the localscript but its ok it should work now
localscript :
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DeletedoorRemote = ReplicatedStorage:WaitForChild("Deletedoor")
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local mouse = localPlayer:GetMouse()
script.Parent = localPlayer.Backpack:WaitForChild("MasterKey")
mouse.Button1Down:Connect(function()
if mouse.Target then
if mouse.Target.Name == "DoorPart" and mouse.Target.Parent.Name == "Door" then
print("Mouse")
DeletedoorRemote:FireServer(mouse.Target.Parent.Parent)
end
end
end)
Doorpart thats inside the door model basically acts like a hitbox if player clicks it than client sends message to server and server does the value updating you could make script delete the door and etc
no but if you want you could remove it since script doesnt really use it youcan add the rbxm file of the door model i sent you and see if it works (dont forget to put the door model into builds folder in workspace)
Since door model is being destroyed theres no point of updating value of it to true
Server script :
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DeletedoorRemote = ReplicatedStorage:WaitForChild("Deletedoor")
DeletedoorRemote.OnServerEvent:Connect(function(Player,DoorModel)
if not DoorModel:FindFirstChild("DoorDestroyValue") then
warn("DoorDestroyValue is missing from DoorPart")
return
end
DoorModel:Destroy()
end)