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
this is my game* Studio Roblox
please help me, any answer will be accepted
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)
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
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,
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)
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)