#Scope system not working

1 messages · Page 1 of 1 (latest)

mental vigil
#

can u please help

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local uis = game:GetService("UserInputService")
local runserv = game:GetService("RunService")

local cam = game.Workspace.CurrentCamera

local aim = CFrame.new()
local isAiming

local weaponsystem = {
    inv = {"AK12/76"};
    model = nil;
}

function loadSlot(i)
    local weaponsFolder = game.ReplicatedStorage.Weapons
    
    weaponsystem.model = weaponsFolder:FindFirstChild(i):Clone()
    weaponsystem.model.Name = "equippedweapon"
    weaponsystem.model.Parent = game.Workspace
end

loadSlot(weaponsystem.inv[1])

runserv.PreRender:Connect(function()
    local v = game.Workspace.equippedweapon
    v:SetPrimaryPartCFrame(cam.CFrame * aim)
    
    if isAiming and weaponsystem.model ~= nil then
        --local offset = weaponsystem.model["AK12/76"].Model.Parts["Cylinder.005"].CFrame:ToObjectSpace(weaponsystem.model.PrimaryPart.CFrame)
        local offset = weaponsystem.model["AK12/76"].Model.Parts.Aimpoint.CFrame:ToObjectSpace(weaponsystem.model.PrimaryPart.CFrame)
        aim = aim:Lerp(offset, .15)
    else
        local offset = CFrame.new()
        aim = aim:Lerp(offset, .15)
    end
end)

uis.InputBegan:Connect(function(inp)
    if inp.UserInputType == Enum.UserInputType.MouseButton2 then
        print("aiming")
        isAiming = true
    end
end)

uis.InputEnded:Connect(function(inp)
    if inp.UserInputType == Enum.UserInputType.MouseButton2 then
        print("aiming ended")
        isAiming = false
    end
end)
chilly bear
#

help with what exactly? not working how? looks working to me.

pseudo widget
#

clearly is the stock

#

LMAO the whole view model gets rotated around

chilly bear
chilly bear
# pseudo widget right
        local offset = weaponsystem.model["AK12/76"].Model.Parts.Aimpoint.CFrame:ToObjectSpace(weaponsystem.model.PrimaryPart.CFrame)
... second one...
        local offset = CFrame.new()``` this is the first part of what defines anything about the model, not sure what aimpoint is meant to be, maybe that is what is backwards? at worst all you gotta add is a *CFrame.Angles(0,-180,0)
#

not sure where though but one of them

#

if the aimpoint is a part that is supposed to be where this moves to, maybe that part is rotated backwards

#

lots of possible ;o

pseudo widget
#

@mental vigil check the above^ : )

mental vigil
#

nvm got it fixed

mental vigil
#

but i added in a new part called aimpart and set the cframe to that

#

i placed the part near the scope

chilly bear
chilly bear