hello, i get this warning “SetPartCollisionGroup is deprecated, please use BasePart.CollisionGroup instead” even tho im not using SetPartCollisionGroup, why is it doing this?
local RunService = game:GetService("RunService")
local PhysicsService = game:GetService("PhysicsService")
local UserInputService = game:GetService("UserInputService")
UserInputService.MouseIconEnabled = false
local Camera = workspace.CurrentCamera
if Camera:FindFirstChild("ViewModel") then
Camera.ViewModel:Destroy()
end
local player = game.Players.LocalPlayer
local Character = script.Parent.Parent
local Head = Character:WaitForChild("Head")
local CameraModule = require(game:GetService("ReplicatedStorage"):WaitForChild("Game Scripts"):WaitForChild("CameraModule"))
local isInFirstPerson = true -- Already set first person in the headbob script
local ViewModelHandler = require(script:WaitForChild("ViewModelHandler"))
local ViewModel = ViewModelHandler.Setup(Character)
local Animator = Character:WaitForChild("Humanoid"):WaitForChild("Animator") -- We need the animator to replicate animations to the ViewModel.
local ViewModelAnimator = ViewModel.Humanoid.Animator -- Used to play animations on the ViewModel.
local LoadedAnimations = {}
Animator.AnimationPlayed:Connect(function(AnimationTrack)
if AnimationTrack:GetAttribute("ViewModelAnimation") ~= true then return end -- // Skip animation if it isn't supposed to play on ViewModel.
if not LoadedAnimations[AnimationTrack] then -- // Indexing using the animation track.
-- // If this animation was not already laoded then load it.
LoadedAnimations[AnimationTrack] = ViewModelAnimator:LoadAnimation(AnimationTrack.Animation) -- // Load animation on the ViewModel.
LoadedAnimations[AnimationTrack].Priority = AnimationTrack.Priority -- Set priority of animations
end
end)
local function updateAnimations()
for CharAnim, Anim in pairs(LoadedAnimations) do
if CharAnim.IsPlaying ~= Anim.IsPlaying then
if CharAnim.IsPlaying then
Anim:Play()
else
Anim:Stop()
end
end
Anim.TimePosition = CharAnim.TimePosition
Anim:AdjustWeight(CharAnim.WeightCurrent, 0) -- // 0 Fade time so it's instantly set.
end
end
local function WeldToViewModel(Tool)
local weld = Character:FindFirstChild("RightGrip", true)
if weld then
if isInFirstPerson == true then
weld.Part0 = ViewModel[weld.Part0.Name]
elseif isInFirstPerson == false then
weld.Part0 = Character[weld.Part0.Name]
end
end
end
Head:GetPropertyChangedSignal('LocalTransparencyModifier'):Connect(function()
if Head.LocalTransparencyModifier == 1 then
isInFirstPerson = true -- player is in 1st person
else
isInFirstPerson = false -- player is not in 1st person
end
local Tool = Character:FindFirstChildWhichIsA("Tool")
if Tool then
WeldToViewModel(Tool)
end
end)
RunService.RenderStepped:Connect(function(dl)
if isInFirstPerson == true then
updateAnimations()
ViewModel:SetPrimaryPartCFrame(Camera.CFrame)
local ViewModelShirt = ViewModel:FindFirstChildWhichIsA("Shirt") or Instance.new("Shirt", ViewModel) -- // Create a shirt if there is no shirt found.
local CharacterShirt = Character:FindFirstChildWhichIsA("Shirt")
if CharacterShirt then
-- // If a shirt was found in the player's character, then set the ViewModel's shirt to the same shirt.
ViewModelShirt.ShirtTemplate = CharacterShirt.ShirtTemplate
end
for _, Part in pairs(ViewModel:GetChildren()) do
if Part:IsA("BasePart") then
-- // Set the color of each part of the ViewModel to the color of the part with same name in the character.
Part.Color = Character[Part.Name].Color
end
end
else
ViewModel:SetPrimaryPartCFrame(CFrame.new(1000000,1000000,1000000))
end
end)
Character.ChildAdded:Connect(function(child)
if child:IsA("Tool") then
if isInFirstPerson == true then
wait()
WeldToViewModel(child)
end
end
end)