I've got my viewmodel working and all, but Its only facing one direction- It doesn't change when I face another direction. How would I do that? This is what I have currently:
local clone = game.Workspace.AWP:Clone() clone.Parent = game.Workspace game:GetService("RunService").RenderStepped:connect(function() print("ok") clone:SetPrimaryPartCFrame(CFrame.new(game.Workspace.Camera.CoordinateFrame.Position)) end)
and yes I have tried googling before coming here.
Thanks in advance.
clone:SetPrimaryPartCFrame(CFrame.new(game.Workspace.Camera.CoordinateFrame))
The problem with this is it makes a new cframe (with default rotation) and simply sets it's position to that of the camera. Instead, try:
clone:SetPrimaryPartCFrame(game.Workspace.Camera.CoordinateFrame)
However there's still an issue with this. This will only work in studio testing. Instead, I would simply do either of these..
If you wish for client side viewmodel with no one else seeing it, do this in a local script placed in StarterPlayerScripts.
local player = script.Parent.Parent player.CharacterAdded:Connect(function(char) --detects when spawning each time local camera = game.Workspace.CurrentCamera local clone = game.Workspace.AWP:Clone() --Makes clone clone.Parent = game.Workspace game:GetService("RunService").RenderStepped:Connect(function() if clone then clone:SetPrimaryPartCFrame(game.Workspace.Camera.CoordinateFrame) end end) end)
The reason that your viewmodel only points one direction is that you only change it's direction once. Add a loop on line 13:
while true do wait () clone:SetPrimaryPartCFrame(CFrame.new(game.Workspace.Camera.CoordinateFrame.Position)) end
This may work in studio, but in a real game camera cannot be accessed from the server.
EDIT: this won't fix all your problems because filtering enabled. Plus, a ROBLOX game works differently than a studio test in that it is multi player. I don't know what that would do to getting camera from workspace