How to this? arrow hit door

I really want to make an arrow in my game, but the arrow I made can’t hit parts or doors,
is there any solution for my problem

1 this game

  1. this is my game* Studio Roblox

please help me, any answer will be accepted :face_holding_back_tears:

Code [1]

local Module = require(game.ReplicatedStorage.Settings)
local Remotes = game:GetService('ReplicatedStorage').ArahFolderE

game.Players.PlayerAdded:Connect(function(Player)
	if Player:FindFirstChild("TitikArahP") then
		return
	end

	local Characters = game.Workspace.FolderArah:GetChildren()
	local RandomCharacter = Characters[math.random(1, #Characters)]

	Remotes.ArahPlayer:FireClient(Player, RandomCharacter)

	local HasDelivery = Instance.new('StringValue', Player)
	HasDelivery.Name = "TitikArahP"
	HasDelivery.Value = RandomCharacter.Name
end)

for i, Remote in pairs(game.ReplicatedStorage.ArahFolderE.ArahEvents:GetChildren()) do
	if Remote:IsA('RemoteEvent') then
		Remote.OnServerEvent:Connect(function(Player)
			if Player:FindFirstChild('TitikArahP').Value == Remote.Name then
				local Character = game.Workspace:FindFirstChild('FolderArah'):FindFirstChild(Remote.Name)
				local PlayerCharacter = Player.Character
	
				while wait(0.1) do
					if (Character.Layar.Position - PlayerCharacter.HumanoidRootPart.Position).Magnitude < Module.PlayerARAHTik then
						game.Debris:AddItem(Player:FindFirstChild('TitikArahP'), 0.1)
						break
					end
				end
				
			end
		end)
	end
end

Code [2]

local Remotes = game:GetService('ReplicatedStorage').ArahFolderE
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local PlayerARAHTik = require(game.ReplicatedStorage.Settings).PlayerARAHTik

function CheckDistcance(ArahPlayerTitik)
	ArahPlayerTitik.Touched:Connect(function(hit)
		local DumHumanoidRootPart = ArahPlayerTitik:WaitForChild("Layar")
		local PlayerHumanoidRootPart = Character:WaitForChild('HumanoidRootPart')

	if (DumHumanoidRootPart.Position - PlayerHumanoidRootPart.Position).Magnitude < PlayerARAHTik then
		
	end
	end)
end


Remotes.ArahPlayer.OnClientEvent:Connect(function(ArahPlayerTitik)
	local ChrAtt = Player.Character:FindFirstChild('HumanoidRootPart'):FindFirstChild('RootAttachment')
	local ChrToDilatt = ArahPlayerTitik:FindFirstChild('Layar'):FindFirstChild('Attachment')
	local newbeam = game.ReplicatedStorage.Settings:FindFirstChild('Titik Arah'):Clone()
	
	newbeam.Parent = ChrAtt
	newbeam.Attachment0 = ChrAtt
	newbeam.Attachment1 = ChrToDilatt
	
	while wait(0.1) do
		local DumHumanoidRootPart = ArahPlayerTitik:WaitForChild("Layar")
		local PlayerHumanoidRootPart = Character:WaitForChild('HumanoidRootPart')

		if (DumHumanoidRootPart.Position - PlayerHumanoidRootPart.Position).Magnitude < PlayerARAHTik then
			if Player:FindFirstChild('TitikArahP') and Player:FindFirstChild('TitikArahP').Value == ArahPlayerTitik.Name then
				Remotes.ArahEvents:FindFirstChild(ArahPlayerTitik.Name):FireServer()
				
				if newbeam then
					newbeam:Destroy()
					DumHumanoidRootPart.CanCollide = false
					DumHumanoidRootPart.Transparency = 1
					DumHumanoidRootPart.Sound:Play()
				end
			end
			break
		end
	end
end)

just change the door attachment and make it inside the door that should fix it

when you showed the attachment position in the vidio it was far away from the door that is why

and instead of checking if the player is near the attachment check when the door is touched with
door.Touched:Connect()

2 Likes

do you mean like this?

    local ChrAtt  = Player.Character:FindFirstChild('HumanoidRootPart'):FindFirstChild('RootAttachment')
	local ChrToDilatt = ArahPlayerTitik:FindFirstChild('Layar')
	local ChrToDilatt2 = ArahPlayerTitik:FindFirstChild('Layar'):FindFirstChild('Attachment')
	local newbeam = game.ReplicatedStorage.Settings:FindFirstChild('Titik Arah'):Clone()
	
	newbeam.Parent = ChrAtt
	newbeam.Attachment0 = ChrAtt
	newbeam.Attachment1 = ChrToDilatt2

1 Like

yes change the position of the attachment that is near the door

1 Like

I don’t understand, can you give me an example, by copying my script?

you used beams and attachment to make that arrow thing right?
the attachment that you placed in the door isnot in the right position you should change its position

1 Like


this???

1 Like

yes move it so it become inside the door

1 Like

no that’s not what i mean, why when i want to fight the door the door doesn’t disappear, but if i fight the Attachment the door will disappear and also the arrow,

do you mean when you touch the door?

yes that’s what i mean :face_holding_back_tears: :pray: :pray:

ok you can check when the door is touched with Door.Touched event instead of checking the distance with the attachement

you can make it smt like this


local Door = workspace.Baseplate -- Replace With Your Door

Door.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		-- Add Your Code Here
	end
end)

Code???

local Door = workspace.FolderArah.ArahPart.Layar -- Replace With Your Door

Door.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		Remotes.ArahPlayer.OnClientEvent:Connect(function(ArahPlayerTitik)
			local ChrAtt = Player.Character:FindFirstChild('HumanoidRootPart'):FindFirstChild('RootAttachment')
			local ChrToDilatt = ArahPlayerTitik:FindFirstChild('Layar')
			local ChrToDilatt2 = ArahPlayerTitik:FindFirstChild('Layar'):FindFirstChild('Attachment')
			local newbeam = game.ReplicatedStorage.Settings:FindFirstChild('Titik Arah'):Clone()

			newbeam.Parent = ChrAtt
			newbeam.Attachment0 = ChrAtt
			newbeam.Attachment1 = ChrToDilatt2

			while wait(0.1) do
				local DumHumanoidRootPart = ArahPlayerTitik:WaitForChild("Layar")
				local PlayerHumanoidRootPart = Character:WaitForChild('HumanoidRootPart')

				if (DumHumanoidRootPart.Position - PlayerHumanoidRootPart.Position).Magnitude < PlayerARAHTik then
					if Player:FindFirstChild('TitikArahP') and Player:FindFirstChild('TitikArahP').Value == ArahPlayerTitik.Name then
						Remotes.ArahEvents:FindFirstChild(ArahPlayerTitik.Name):FireServer()

						if newbeam then
							newbeam:Destroy()
							DumHumanoidRootPart.CanCollide = false
							DumHumanoidRootPart.Transparency = 1
							DumHumanoidRootPart.Sound:Play()
						end
					end
					break
				end
			end
		end)
	end
end)

i canot understand the variables/names in your code but i think that you are checking if the player is near the attachment what you can do instead is use Door.Touched
you can use this to detect when the door is touched instead

local Players = game:GetService("Players")
local Door = workspace.Baseplate -- Replace With Your Door

Door.Touched:Connect(function(hit) -- Fires When The Door Is Touched
	if hit.Parent:FindFirstChild("Humanoid") then
		local Character = hit.Parent -- The Character That Touched The Door
		local Player = Players:GetPlayerFromCharacter(Character) -- The Player
		
		-- Add Your Code Here
	end
end)
1 Like

yes, thank you for your answer, this isn’t it, although it only works for doors :pensive:

1 Like