Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My part is supposed to delete. Why dosn't it work?

Hey guys, I have a problem with my part that should delete, but it dosn't work when deleting it I'll show the script in a pastebin, beacuse it's quite much code. I also want to save space here. I had a RemoteEvent, as I knew you needed a RemoteEvent.

Client/Local Script: https://pastebin.com/hjUjGtWJ

MainScript/Server Script: https://pastebin.com/T6VLhbR2

If you're asking me if there was any errors, there was no when I did, but there was no errors in the output. All I could see was errors from plugins, and warnings.

If you help me, thank you so much!

Sincerely,

Ducksneedhelp

1 answer

The first problem is that you are not checking if the player is chatting, that means if they say "Hello friend", it has a D and the part will delete, to fix this, use 2nd argument of the userinputservice inputbegan function so do:

UserInputService.InputBegan:Connect(function(input,isTyping)
	if isTyping then return end -- if the player is typing then stop the function
	if input.KeyCode == Enum.KeyCode.D then
		-- Code
	end
end)

the second problem is that the remote event in both scripts is differently named, so thats why it doesnt delete

LocalScript:

local Delete = ReplicatedStorage:WaitForChild("Delete") -- it's named delete 

ServerScript:

local DeletePart = ReplicatedStorage:WaitForChild("DeletePart") -- Its named deletepart

to fix it change the name of the remote event to "DeletePart and in the localscript, change it to deletepart

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DeletePart = ReplicatedStorage:WaitForChild("DeletePart")
local UserInputService = game:GetService("UserInputService")
local part = game.Workspace.Part
 
 
UserInputService.InputBegan:Connect(function(input,isTyping)
	if isTyping then return end
	if input.KeyCode == Enum.KeyCode.D then
		print("C is Pressed, and the part is going to destroy shortly!")
		DeletePart:FireServer(part)
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.