I'm new to scripting and I'm trying to make a grenade compatible with filtering enabled. In a local test it works like it should, but in a team test the grenade throws but in one specific direction. What I mean by this is that if I aim at a specific point, the grenade could, say, throw behind me as if it was heading toward one specific spot. It's probably something simple I'm missing, but it ALWAYS goes towards the same exact direction no matter which way my character faces. Any help would be greatly appreciated.
Tool = script.Parent
function fire(v)
Tool.Handle.Fire:play()
local vCharacter = Tool.Parent
local vPlayer = game.Players:playerFromCharacter(vCharacter)
local missile = Instance.new("Part")
local spawnPos = vCharacter.PrimaryPart.Position
Tool.GripPos = Vector3.new(0, 0.4, 0.5)
vCharacter.Torso["Right Shoulder"].CurrentAngle = 3
spawnPos = spawnPos + (v * 8)
missile.Position = spawnPos
missile.Size = Vector3.new(1,1,1)
missile.Velocity = v * 60
missile.Name = "Grenade"
missile.BrickColor = BrickColor.new("Medium green")
local force = Instance.new("BodyForce")
force.force = Vector3.new(0,100,0)
force.Parent = missile
Tool.Sound:clone().Parent = missile
Tool.Kill:clone().Parent = missile
Tool.Smoke:clone().Parent = missile
Tool.Handle.Mesh:clone().Parent = missile
Tool.Script:clone().Parent = missile
local counter = Instance.new("ObjectValue")
counter.Value = game.Players:GetPlayerFromCharacter(Tool.Parent)
counter.Parent = missile
counter.Name = "creator"
missile.Parent = game.Workspace
end
Tool.Enabled = true
function onActivated()
if not Tool.Enabled then
return
end
Tool.Enabled = false
local character = Tool.Parent;
local humanoid = character.Humanoid
if humanoid == nil then
print("Humanoid not found")
return
end
local targetPos = humanoid.TargetPoint
local lookAt = (targetPos - character.Head.Position).unit
fire(lookAt)
wait(0.1)
Tool.Parent = nil
end
script.Parent.Activated:connect(onActivated)

1 comment
I have already read those two articles before, issue is I'm looking for what to do in this particular scenario