Hey guys!
I am creating a bow and arrow. It worked perfectly in studio, everything expected.
I invited my friend to test it with me in player, until he wasn’t there the arrow was working nice, as soon as he joined the movement of the arrow stopped (raycast still worked tho)
script:
script.Parent.Arrow.Name = script.Parent.Parent.Parent.Name .. "Arrow"
script.Parent.RemoteEvent.OnServerEvent:Connect(function(player, mouseP, enabled)
if player ~= nil then
if enabled then
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {player.Character}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastresult = workspace:Raycast(script.Parent.ArrowPart.Position, (mouseP - script.Parent.ArrowPart.Position) * 300, raycastParams)
if raycastresult then
if script.Parent:WaitForChild(player.Name.."Arrow") then
local hitPart = raycastresult.Instance
local model = hitPart:FindFirstAncestorOfClass("Model")
if model then
if model:FindFirstChildWhichIsA("Humanoid") then
if hitPart.Name == "Head" then
local hum = model:FindFirstChildWhichIsA("Humanoid")
hum.Health = hum.Health - 30
elseif hitPart.Name ~= "Head" then
local hum = model:FindFirstChildWhichIsA("Humanoid")
hum.Health = hum.Health - 10
end
end
end
else
print("no arrow :|")
end
end
makeLaser(mouseP, player.Name)
end
end
end)
function makeLaser(mouse, plr)
local newArrow = script.Parent:WaitForChild(plr.."Arrow"):Clone()
local Distance = (script.Parent.ArrowPart.Position - mouse).magnitude
local Part = Instance.new("Part", script.Parent)
Part.Name = plr.."laser"
Part.CanCollide = false
Part.BrickColor = BrickColor.new("White")
Part.Transparency = 0.7
Part.Size = Vector3.new(0.2, 0.2, Distance)
Part.CFrame = CFrame.lookAt(script.Parent.ArrowPart.Position, mouse) * CFrame.new(0,0,-(Distance/2))
Part.Anchored = true
wait(0.1)
local arrow
if script.Parent[plr.."Arrow"] then
arrow = script.Parent[plr.."Arrow"]
else
end
arrow.Union.Orientation = Part.Orientation + Vector3.new(-90, 0, -90)
arrow.Parent = workspace
arrow.Union.Main:Destroy()
arrow.Union.Position = mouse
arrow.Union.CanCollide = false
arrow.Union.Anchored = true
print(Part.Orientation)
Part:Destroy()
wait(2)
arrow:Destroy()
newArrow.Parent = script.Parent
newArrow.Name = plr.."Arrow"
end
There are no errors. Help is appreciated.
Thanks