Hello So I have this gun in my game but the character holds it weirdly. I want to change how he's holding it. Heres the script:
local Tool = script.Parent
local Handle = Tool:WaitForChild("Handle")
local market = game:GetService("MarketplaceService")
local turnRate = 36
local mouse
local idleAnim
local humanoid
local player
while not player do
if script.Parent.Parent:IsA("Model") then
player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
elseif script.Parent.Parent:IsA("Backpack") then
player = script.Parent.Parent.Parent
end
wait()
end
function RayIgnoreCheck(hit, pos)
if hit and (hit.Transparency > 0 or hit.Name == "Bullet" or hit.Name == "Handle" or hit:IsDescendantOf(char)) then
return true
end
return false
end
function RayCast(startPos, vec, rayLength)
local hitObject, hitPos = game.Workspace:FindPartOnRay(Ray.new(startPos + (vec * .01), vec * rayLength), Handle)
if hitObject and hitPos then
local distance = rayLength - (hitPos - startPos).magnitude
if RayIgnoreCheck(hitObject, hitPos) and distance > 0 then
return RayCast(hitPos, vec, distance)
end
end
return hitObject, hitPos
end
local function CreateBullet(bulletPos)
local bullet = Instance.new("Part")
bullet.CanCollide = false
bullet.Anchored = true
bullet.Name = "Bullet"
bullet.Transparency = 1
bullet.Parent = workspace
bullet.CFrame = CFrame.new(bulletPos)
game:GetService("Debris"):AddItem(bullet, 2.5)
local g = script.Bullet:clone()
g.Parent = bullet
g.Img.Script.Disabled = false
game:GetService("Debris"):AddItem(Instance.new("PointLight",bullet),0.2)
return bullet
end
function getGrip()
if char then
if char:findFirstChild("RightHand") then
if char["RightHand"]:findFirstChild("RightHandGrip") then
return char["RightHand"].RightGrip
end
end
end
end
function ReloadAnim(spinRate)
delay(0.1,function ()
local grip = getGrip()
if grip then
local originalGrip = grip.C0
for i = 1,spinRate do
grip.C0 = grip.C0 * CFrame.fromEulerAnglesXYZ(math.pi/(spinRate/4),0,0)
wait()
end
grip.C0 = originalGrip
end
end)
RELOAD_ANIM = humanoid:LoadAnimation(script.Parent.Reload)
RELOAD_ANIM:Play(0.1,1,spinRate < 36 and 3 or 2)
Handle.Reload:Play()
end
function Shoot(player,target)
if not Tool.Enabled then return end
if not humanoid then return end
Tool.Enabled = false
Handle.FireSound:Play()
humanoid:LoadAnimation(script.Parent.FireAni):Play()
local hitObject, bulletPos = RayCast(Handle.Position,CFrame.Angles((.5-math.random())*4*.05,(.5-math.random())*3*.05,(.5-math.random())*4*.05)*((target - Handle.Position).unit), 400)
if hitObject then
CreateBullet(bulletPos)
if hitObject.Parent then
local hitHumanoid = hitObject.Parent:findFirstChild("Humanoid")
if hitHumanoid and game.Players:GetPlayerFromCharacter(hitHumanoid.Parent) ~= player then
hitHumanoid.Health = 0
end
end
end
wait(1)
ReloadAnim(turnRate)
wait(turnRate/12)
Tool.Enabled = true
end
local fireInput = script.Parent:WaitForChild("FireWeapon")
fireInput.OnServerEvent:connect(Shoot)
function OnEquipped(m)
char = script.Parent.Parent
humanoid = char:WaitForChild("Humanoid")
mouse = m
end
function OnUnequipped()
mouse = nil
end
Tool.Equipped:connect(OnEquipped)
Tool.Unequipped:connect(OnUnequipped)
What part should I change?

2 comments
Use a plugin. I use "Tool Grip Editor".
Yeah use that I use it aswell and its really helps