While true do loop only printing one string

I got this warning from line 24

19:56:38.414 DoorDestroyValue is missing from DoorPart - Server - Script:24

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)

One question, where should the local script be, because it is in the MasterKey tool.

you could update already existing localscript to this new code

I have updated the code to my local script. But the door still doesn’t destroy

could you save the door model and tool that has localscript as rbxl and send it here and ill test and fix it for you

to save the model as file right click the model and press “Save to file”

image

Sure,

Door Model:
DoorModel.rbxm (34.7 KB)

MasterKey:
MasterKey.rbxm (11.9 KB)

1 Like

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)

Updated door model :

DoorModel.rbxm (34.8 KB)

image

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

Would i need to remove the Click Detector in DoorPart?

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)

1 Like

This is my output. But, the door has not been destroyed.

image_2024-12-24_202343742

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)
1 Like

THANK YOU!!! I appreciate you helping me with this!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.