Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Launderer 343 Moderation Voter
5 years ago
Edited 5 years ago

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.

0
Also sorry for the gif links not being in the link format, everytime I did that they would just break. Launderer 343 — 5y
0
The parent argument to Instance.new is deprecated User#19524 175 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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
Ad

Answer this question