This is my first post on the forums and I’d consider myself a novice coder. My game is pretty simple, it’s mostly a collection of tools and models with some fun mechanics, nothing fancy.
I have some parts scattered around the map that allow the player to pose when they interact with them (think of XYZ Public Bathroom). However, the more the player interacts with these poses, the further off-aim the rocket launcher I put in the starter pack gets. For example, if a player poses and un-poses just a few times in a row, the rockets from the launcher will spawn about 5 studs up and 5 studs out from the player’s head each time they use it, making aiming difficult.
The rocket launcher is the same launcher that Roblox themselves posted in the Tool Box, albeit with some minor tweaks and a new model. The rocket direction is determined via lookVector and the spawn position is determined by the “hole” on the launcher from which the rocket would realistically fire from. It aims and spawns perfectly fine until the player poses.
-- Position the rocket clone and launch!
local spawnPosition = (Tool.Hole.CFrame * CFrame.new(0.2, 0, 0)).p
rocketClone.CFrame = CFrame.new(spawnPosition, Pos) --NOTE: This must be done before assigning Parent
rocketClone.Velocity = rocketClone.CFrame.lookVector * ROCKET_SPEED --NOTE: This should be done before assigning Parent
rocketClone.Parent = workspace
rocketClone:SetNetworkOwner(nil)
task.wait(RELOAD_TIME)
Meanwhile, the pose script I use snaps the player’s HumanoidRootPart to a specific location/direction based on the player’s scaling settings, to prevent too tall/short of characters from appearing to float or sink into the ground.
local root = plr.Character:FindFirstChild("HumanoidRootPart")
root.Anchored = true
root.Position = part.Position + Vector3.new(0, ((part.Value1.Value * hum.BodyHeightScale.Value) + (hum.BodyTypeScale.Value * part.Value2.Value) - (hum.BodyProportionScale.Value * 0.1)), 0)
root.Orientation = part.Orientation
animation:Play()
I suspect this is messing with the CFrame of where the rocket is spawning, but IDK enough about Cframes to fix it…
More code or some screenshots can be provided if needed
PS: I’m heading out of the house soon and may not reply quickly