Hello i was following a tutorial but when i tested it the bullet hole wasn't rotated
local script inside the gun:
script.Parent.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
game.ReplicatedStorage.RayCastEvent:FireServer(script.Parent.BulHol.CFrame.Position, mouse.Hit.Position)
end)
end)
normal script in the ServerScriptService:
game.ReplicatedStorage.RayCastEvent.OnServerEvent:Connect(function(Player, FromP, ToP)
local RayCast = Ray.new(FromP,(ToP-FromP).unit*100)
local Part,Position,Normal = game.Workspace:FindPartOnRay(RayCast,Player.Character, false,true)
local Dist = (ToP-FromP).magnitude
if not Dist then Dist = 300 end
local Lazer = Instance.new("Part")
Lazer.Parent = game.Workspace
Lazer.Anchored = true
Lazer.CanCollide = false
Lazer.Size = Vector3.new(0.1,0.1,Dist)
Lazer.CFrame = CFrame.new(FromP,Position)*CFrame.new(0,0,-Dist/2)
local Hole = game.ReplicatedStorage.Hole:Clone()
Hole.Parent = Part.Parent
Hole.Position = ToP
Hole.CFrame = CFrame.new(Hole.Position, Hole.Position+Normal)
local Weld = Instance.new("Weld")
Weld.Part0 = Part
Weld.Part1 = Hole
Weld.C0 = Part.CFrame:Inverse()
Weld.C1 = Hole.CFrame:Inverse()
Weld.Parent = Hole
game.Debris:AddItem(Lazer,0.2)
if Part and Part.Parent:FindFirstChild("Humanoid") then
Part.Parent.Humanoid:TakeDamage(30)
end
game.Debris:AddItem(Hole,10)
end)
edit: https://www.youtube.com/watch?v=OWlzX334grI heres the video
