#Viewmodel not appearing

58 messages · Page 1 of 1 (latest)

lucid fable
#

So apparently, I've done everything on Xaradev's part 1 of FPS tutorial including the scripting part. But the models did not seem to appear. Am I missing something? Any solution?

daring bridge
#

try adding a .Name to this

#

since ur trying to find an instance from an instance not a string

lucid fable
daring bridge
#

no

#

framework.inventory[1].Name

#

also it should be "1"

#

like ["1"]

#

wait

#

no

#

its a table

#

i see

lucid fable
#

?

daring bridge
#

try some debugging

#

like prints every so often

#

to see how far it reaches

lucid fable
#

er.. im pretty new about all of this so what is that suppose to mean?

daring bridge
#

example:

print("1")
if blah blah then
print("2")
end
--and on and on
lucid fable
#

so i just make another script and try to type that over and over or smth?

torpid pivotBOT
#

studio** You are now Level 1! **studio

daring bridge
#

no

#

hold on can u send the script

lucid fable
#

ok

#

wait how do u send that example on that style?

fathom geode
lucid fable
#

aight

fathom geode
#

`

lucid fable
#
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

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

local camera = game.Workspace.CurrentCamera

local framework = {
    inventory = {
        "M92A5";
        "RTP .45";
        "Combat Dagger";
        "Bobm";
    };
    
    module = nil;
    viewmodel = nil;
}

function loadSlot(Item)
    local viewmodelFolder = game.ReplicatedStorage.Viewmodels.M92A5
    local moduleFolder = game.ReplicatedStorage.Modules.M92A5
    
    if moduleFolder:FindFirstChild(Item) then 
        framework.module = require(moduleFolder:FindFirstChild(Item))
        
        if viewmodelFolder:FindFirstChild(Item) then 
            framework.viewmodel = viewmodelFolder:FindFirstChild(Item):Clone()
            framework.viewmodel.Parent = camera    
            
            
        end
    end
end

RunService.RenderStepped:Connect(function()
    for i, v in pairs(camera:GetChildren()) do
        if v:IsA("Model") then
            v:PivotTo(camera.CFrame)
        end
    end
end)

loadSlot(framework.inventory[1])
daring bridge
#
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

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

local camera = game.Workspace.CurrentCamera

local framework = {
    inventory = {
        "M92A5";
        "RTP .45";
        "Combat Dagger";
        "Bobm";
    };

    module = nil;
    viewmodel = nil;
}

function loadSlot(Item)
    local viewmodelFolder = game.ReplicatedStorage.Viewmodels
    local moduleFolder = game.ReplicatedStorage.Modules

    if moduleFolder:FindFirstChild(Item) then 
        framework.module = require(moduleFolder:FindFirstChild(Item))

        if viewmodelFolder:FindFirstChild(Item) then 
            framework.viewmodel = viewmodelFolder:FindFirstChild(Item):Clone()
            framework.viewmodel.Parent = camera    


        end
    end
end

RunService.RenderStepped:Connect(function()
    for i, v in pairs(camera:GetChildren()) do
        if v:IsA("Model") then
            v:PivotTo(camera.CFrame)
        end
    end
end)

loadSlot(framework.inventory[1])
#

there u go

#

i just realized u had the folders set to a specific gun

lucid fable
#

ooo

#

what part did you change, if I may ask?

daring bridge
#

before

#

ur try to find a gun in the gun itself

lucid fable
#

ooh

#

lemme try

#

IT WORKED!

#

Thank you!!

daring bridge
#

mark it as solved

lucid fable
#

aight

#

done

tulip prawn
#

dammm

#

What does the script do

#

@lucid fable

lucid fable
#

for an FPS game im trying to make for fun

tulip prawn
#

A view model?

lucid fable
tulip prawn
#

Idk what that is

daring bridge
#

its solved anyways

tulip prawn
#

Still I wanna see

lucid fable
#

watch FPS tutorial by Xeradev from part 1 if ya wanna check

daring bridge
#

viewmodels are u holding the weapon in first person u see in games

tulip prawn
#

Ohhh

lucid fable
#

yep