#Trying to make a viewmodel that matches players arms
1 messages · Page 1 of 1 (latest)
Also ignore the sway variables, thats something unrelated
I'm using a template script so there might be some unrelated code, just look where it says "tool.Equipped"
I’m not quite sure what ur trying to do but turning off massless and can collide might work
Oh wait i figured it out, its because i was anchoring it
Okay but now i have another problem, for some reason the hand isnt moving with the camera
Can someone plz help
it's cuz when the tool is equipped, the defuault holding position for a character is to extend it's arm, like the classic sword or something
and you're movin the gun but not the arm
also it looks like it's a local script, so the arm would only move on the client's side (Other players won't see it), so if it's not for a zombie-style game, but for an FPS, I think the script should be server sided
I'd try to do exactly the same thing as with the gun, to the arm , if I were You. I could also try to do it myself, can You paste the code?
in text
Well its supposed to be a viewmodel for only the player to see when in first person\
Yeah i can paste the code
I'm not able to paste all of it bc of the character limit so I'll leave out the variables at the beginning
Or actually I'll just DM you
Yeah idk its not letting me paste the code for some reason
Can't you paste it in a txt?
local tool = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local RunService = game:GetService("RunService")
local uis = game:GetService("UserInputService")
local ViewModel
local equipped = false
tool.Equipped:Connect(function()
equipped = true
game.ReplicatedStorage.ViewModel:Clone().Parent = Camera
for i, v in pairs(character:GetChildren()) do
if v.Name == "RightHand" then
local part = v:Clone()
part.Parent = Camera.ViewModel.Camera
end
end
end)
tool.Unequipped:Connect(function()
equipped = false
ViewModel = Camera.ViewModel
ViewModel:Destroy()
end)
RunService.RenderStepped:Connect(function()
if player.Character.Humanoid.Health <= 0 then
if Camera:FindFirstChild("ViewModel") ~= nil then
workspace.Camera.ViewModel:Destroy()
end
end
if equipped == true then
if Camera:FindFirstChild("ViewModel") ~= nil then
Camera.ViewModel:SetPrimaryPartCFrame(Camera.CFrame)
for i, v in pairs(Camera.ViewModel:GetChildren()) do
if v:IsA("BasePart") then
v.CanCollide = false
end
end
end
end
end)
Oh there we go
kay leme set it up in roblox studio rq
Just saying for it to work in roblox studio you also need to have a viewmodel in replicated storage
what is viewmodel?
lol the timing
so it's a boolean value
So it wasn't coded by me
Yeah i think so
It just means the viewmodel in the camera
Its the same as "workspace.Camera.Viewmodel"
** You are now Level 6! **
can u send a screen shot of how it looks like in studio?
Okay
like what icon it has or smthn
Like what the explorer looks like?
ye
K one sec
k
what's inside the ViewModel model?
So the template that i used had arms and stuff
So for this i just made them transparent for now
It works with them
But for some reason it doesnt work when the script inserts the players own hand
Like the pre made view model parts work, they follow the camera, but when the players hand is inserted by the script, it doesnt follow the camera for some reaso
yea weird
I grabbed a random viewmodel
and
same thing happens
imma try to fix it somehow
Yeah
Like it works with the pre made parts but not the players hand
I've also tried making a motor6d or a weld constraint between the camera part and the hand but that just seems to bug it out
** You are now Level 17! **
I did it this way
so on the top is the original tool, on the bottom (Which follows the cam) is the pre-made model
Yeah but i need to get the players hand to follow the cam
with the pre-model its easy
but idk how to make it so the actual hand follows
cuz player will prob have different avatar
Yeah, its easy to make the pre made model follow
When i insert the players hand into the viewmodel though, it just doesnt follow the cam and i cant see why, i cant see any difference between the hand and the pre made model...
I dont really know what makes objects follow the camera in the script, cause i got it from a template
the difference is that the other object have a motor6D
and the hand also has one, but its attached to the main bodu
*body
which is in this default position
it behaves weirdly
idk how to fix it
tbh
local tool = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local RunService = game:GetService("RunService")
local uis = game:GetService("UserInputService")
local ViewModel
local equipped = false
tool.Equipped:Connect(function()
equipped = true
game.ReplicatedStorage.ViewModel:Clone().Parent = Camera
for i, v in pairs(character:GetChildren()) do
if v.Name == "RightHand" then
local part = v:Clone()
part.Parent = Camera.ViewModel.Camera
part.Position = game.ReplicatedStorage.ViewModel.PosPart.Position
for _, child in pairs(part:GetChildren()) do
child:Destroy()
end
local motor6D = Instance.new("Motor6D")
motor6D.Parent = part
motor6D.Part0 = part
motor6D.Part1 = game.ReplicatedStorage.ViewModel.PosPart
part.Anchored = true
end
end
end)
tool.Unequipped:Connect(function()
equipped = false
ViewModel = Camera.ViewModel
ViewModel:Destroy()
end)
RunService.RenderStepped:Connect(function()
if player.Character.Humanoid.Health <= 0 then
if Camera:FindFirstChild("ViewModel") ~= nil then
workspace.Camera.ViewModel:Destroy()
end
end
if equipped == true then
if Camera:FindFirstChild("ViewModel") ~= nil then
Camera.ViewModel:SetPrimaryPartCFrame(Camera.CFrame)
for i, v in pairs(Camera.ViewModel:GetChildren()) do
if v:IsA("BasePart") then
v.CanCollide = false
end
end
end
end
end)
code ^^
I could try but I gtg
cya!
Oh thx, i was afk btw, but thats awesome, i think what i was doing wrong is i tried making a motor6d, but i didnt anchor it, which caused it to buig out a ton.
Oh wait, Ugh for some reason its not working for me... Im getting this...
Well whatever ill fix it another dayt
Cya
Oh nice i got it working... ill just put this post as solved
can i see?
actually there's a way to do the hands of a player
you just need the animation of a player holding the gun
then for the viewmodel you just need to do head nad the torso
watch this
How to make a Roblox view model but easy, its r6 because r6 is elite. anyways I have some code I promised you guys at the end of the video:
part 2 : https://youtu.be/eVHL0gX4Leg
https://pastebin.com/raw/gjTbTaFb - Code (YT wouldn't let me put it in desc bc it had angle brackets)
Games that use my model /
https://www.roblox.com/games/876597891...
research about localtransparencymodifier
i wont send any code here. just figure it out by yourself.
Yeah i know but if you wanna make one for the camera only
Dang it now i have another problem