Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I scripted a clientsided camera, there's really weird collision, why?

So I created a script that basically clones the character and puts it into the client's CurrentCamera. Which all worked as it was meant to but I noticed something. There's like this awful collision when jumping however in the CurrentCamera model I have all collision turned off. I have created some gifs to show what is happening.

Here you see the awful collision and spazzing out while showing the selection box.

imgur.com/a/ObbASkB

Then here you see the worst thing that could happen is your character basically gets frozen in the air spazzng out on spawn.

imgur.com/a/5OHi4gw

Then here you can see I scripted it so all collision is turned off on the CurrentCamera model.

imgur.com/a/YnacA5K

Here is my code if you find anything wrong that could enable this awful collision please tell me.

local Players = game:GetService("Players")

local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()

local Camera = workspace.CurrentCamera

local Character = Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

for index, child in ipairs(Character:GetChildren()) do
	if child:IsA("Part") and child.Name == "Head" or child:IsA("MeshPart") then
		local FakeLimb = child:Clone()
		FakeLimb.Parent = Camera
		FakeLimb.CanCollide = false
		FakeLimb.CustomPhysicalProperties = PhysicalProperties.new(0.01, 0, 0, 0, 0)
		
		local Weld = Instance.new("ManualWeld", FakeLimb)
		Weld.Part0 = child
		Weld.Part1 = FakeLimb
	end
end

local FakeHumanoid = Humanoid:Clone()
FakeHumanoid.Parent = Camera

for index, descendant in ipairs(Camera:GetDescendants()) do
	if descendant:IsA("Attachment") or descendant:IsA("Motor6D") or descendant:IsA("Vector3Value") then
		descendant:Destroy()
	end
end

for index, descendant in ipairs(Character:GetDescendants()) do
	if descendant:IsA("Part") and descendant.Name == "Handle" and descendant.Parent:IsA("Accessory") then
		local FakeHat = descendant:Clone()
		FakeHat.Parent = Camera
		FakeHat.Name = "Hat"
		FakeHat.CustomPhysicalProperties = PhysicalProperties.new(0.01, 0, 0, 0, 0)
		
		local Weld = Instance.new("ManualWeld", FakeHat)
		Weld.Part0 = descendant
		Weld.Part1 = FakeHat
	end
end

for index, child in ipairs(Camera:GetChildren()) do
	if child:IsA("MeshPart") then
		child.Material = Enum.Material.SmoothPlastic
	end
end

If you have any solutions to this madness please tell me.

2 comments

0

Also sorry for the gif links not being in the link format, everytime I did that they would just break.

0

The parent argument to Instance.new is deprecated

1 answer

you forgot humanoid

I'm not sure if this 100% solved the problem.

local Players = game:GetService("Players")

local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()

local Camera = workspace.CurrentCamera

local Character = Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

for index, child in ipairs(Character:GetChildren()) do
    if child:IsA("Part") and child.Name == "Head" or child:IsA("MeshPart") then
        local FakeLimb = child:Clone()
        FakeLimb.Parent = Camera
        FakeLimb.CanCollide = false
        FakeLimb.CustomPhysicalProperties = PhysicalProperties.new(0.01, 0, 0, 0, 0)

        local Weld = Instance.new("ManualWeld", FakeLimb)
        Weld.Part0 = child
        Weld.Part1 = FakeLimb
    end
end

local FakeHumanoid = Humanoid:Clone()
FakeHumanoid.Parent = Camera

for index, descendant in ipairs(Camera:GetDescendants()) do
    if descendant:IsA("Attachment") or descendant:IsA("Motor6D") or descendant:IsA("Vector3Value") or descendant.ClassName == "Humanoid" then
        descendant:Destroy()
    end
end

for index, descendant in ipairs(Character:GetDescendants()) do
    if descendant:IsA("Part") and descendant.Name == "Handle" and descendant.Parent:IsA("Accessory") then
        local FakeHat = descendant:Clone()
        FakeHat.Parent = Camera
        FakeHat.Name = "Hat"
        FakeHat.CustomPhysicalProperties = PhysicalProperties.new(0.01, 0, 0, 0, 0)

        local Weld = Instance.new("ManualWeld", FakeHat)
        Weld.Part0 = descendant
        Weld.Part1 = FakeHat
    end
end

for index, child in ipairs(Camera:GetChildren()) do
    if child:IsA("MeshPart") then
        child.Material = Enum.Material.SmoothPlastic
    end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.