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

FPS/TPS Script completely ignoring a line of code I have?!

Asked by 8 years ago

At this point, I'm practically frustrated. I already had trouble with this thing this morning. And I had it all working fine...

Until now. When you reset and try to go into Third Person, the camera doesn't move. All you see is where your camera in First Person, but you can see your torso and arms. I'm almost at the point of shoving my fist through the screen right now. I need help. I simply need help. This stupid script doesn't help me out in any way. It's like scripts now hate me.

Here's my LocalScript in StarterPack:

local ToggleKey = "t"
local Player = game.Players.LocalPlayer
Player.CameraMode = Enum.CameraMode.LockFirstPerson
local Character = Player.Character or Player.CharacterAdded:wait()
local FPS = true
wait(2.5)
local Mouse = Player:GetMouse()
local Camera = game.Workspace.CurrentCamera

local AM = Instance.new("Model", Camera)
local FakeParts = {}
AM.Name = "TPSBody"
Arms = {Player.Character["Left Arm"], Player.Character["Right Arm"]}
Arm1 = Instance.new("Part", AM)
Arm1.Name = "Left Arm"
Arm1.CanCollide = false
Arm1.FormFactor = Enum.FormFactor.Custom
Arm1.Size = Arms[1].Size - Vector3.new(0.1, 0.1, 0.1)
Arm1.BrickColor = Arms[1].BrickColor
table.insert(FakeParts, #FakeParts+1, Arm1)
Arm2 = Instance.new("Part", AM)
Arm2.Name = "Right Arm"
Arm2.CanCollide = false
Arm2.FormFactor = Enum.FormFactor.Custom
Arm2.Size = Arms[2].Size - Vector3.new(0.1, 0.1, 0.1)
Arm2.BrickColor = Arms[2].BrickColor
table.insert(FakeParts, #FakeParts+1, Arm2)
W1 = Instance.new("Weld", Arm1)
W1.Part0 = Arms[1]
W1.Part1 = Arm1
W2 = Instance.new("Weld", Arm2)
W2.Part0 = Arms[2]
W2.Part1 = Arm2
Legs = {Player.Character["Left Leg"], Player.Character["Right Leg"]}
Leg1 = Instance.new("Part", AM)
Leg1.Name = "Left Leg"
Leg1.CanCollide = false
Leg1.FormFactor = Enum.FormFactor.Custom
Leg1.Size = Legs[1].Size
Leg1.BrickColor = Legs[1].BrickColor
table.insert(FakeParts, #FakeParts+1, Leg1)
Leg2 = Instance.new("Part", AM)
Leg2.Name = "Right Leg"
Leg2.CanCollide = false
Leg2.FormFactor = Enum.FormFactor.Custom
Leg2.Size = Legs[2].Size
Leg2.BrickColor = Legs[2].BrickColor
table.insert(FakeParts, #FakeParts+1, Leg2)
W3 = Instance.new("Weld", Leg1)
W3.Part0 = Legs[1]
W3.Part1 = Leg1
W4 = Instance.new("Weld", Leg2)
W4.Part0 = Legs[2]
W4.Part1 = Leg2
Vitals = {Player.Character.Torso, Player.Character.Head}
Tors = Instance.new("Part", AM)
Tors.Name = "Torso"
Tors.CanCollide = false
Tors.FormFactor = Enum.FormFactor.Custom
Tors.Size = Vitals[1].Size
Tors.BrickColor = Vitals[1].BrickColor
table.insert(FakeParts, #FakeParts+1, Tors)
Head = Instance.new("Part", AM)
Head.Name = "FakeHead"
Head.CanCollide = false
Head.FormFactor = Enum.FormFactor.Custom
Head.Size = Vitals[2].Size
Head.BrickColor = Vitals[2].BrickColor
table.insert(FakeParts, #FakeParts+1, Head)
HeadMesh = Vitals[2].Mesh:Clone()
HeadMesh.Parent = Head
HeadMesh.Scale = HeadMesh.Scale - Vector3.new(0.01, 0.01, 0.01)
W5 = Instance.new("Weld", Tors)
W5.Part0 = Vitals[1]
W5.Part1 = Tors
W6 = Instance.new("Weld", Head)
W6.Part0 = Vitals[2]
W6.Part1 = Head

Human = Instance.new("Humanoid", AM)
Human.Name = "FakeHumanoidFake"
print("Here's mah stuff")
for _,Obj in pairs(Player.Character:GetChildren()) do
    if Obj:IsA("CharacterMesh") or Obj:IsA("Shirt") or Obj:IsA("Pants") then
        Obj:Clone().Parent = AM
    end
    if Obj:IsA("Hat") then
        local NewHat = Obj:Clone()
        NewHat.Parent = AM
        table.insert(FakeParts, #FakeParts+1, NewHat.Handle)
        wait()
        local HatWeld = Instance.new("Weld", Head)
        HatWeld.Name = "HatWeld"
        HatWeld.Part0 = NewHat.Handle
        HatWeld.Part1 = Head
        NewHat.Handle.Mesh.Offset = Vector3.new(0, 0.1, 0)
    end
    wait()
end

Character.Humanoid.Died:connect(function()
    AM:Destroy()
    Character.Humanoid.CameraOffset = Vector3.new(0, 0, 0)
    connect:disconnect()
    FPS = true
end)

for i,v in pairs(FakeParts) do
    v.Transparency = 1
end

print("Connecting the mouse...")

connect = Mouse.KeyDown:connect(function(key)
    if key == ToggleKey then
        if FPS then
            FPS = false
            Character.Humanoid.CameraOffset = Vector3.new(1.5, 0.5, 6) --WHY THE- Actually, why the heck does it simply ignore this after you reset ONCE?!
            for i,v in pairs(FakeParts) do
                v.Transparency = 0
            end
        elseif not FPS then
            FPS = true
            Character.Humanoid.CameraOffset = Vector3.new(0, 0, 0) --WHY THE- Actually, why the heck does it simply ignore this after you reset ONCE?!
            for i,v in pairs(FakeParts) do
                v.Transparency = 1
            end
        end
    end
end)

You can see in lines 118 and 124 a comment that shows that the script is simply ignoring the code. I have no idea why, but I think it's ROBLOX's fault. Can anyone please help? I'm desperate!!

0
Um...there's a function that checks to see if a Humanoid dies in the code, and it disconnects the Mouse.KeyDown listening event after they die. Just remove line 104. Do you make starter pack items continue over to the character's respawn? Legojoker 345 — 8y
0
If a script is in StarterPack it usually respawns itself. So in other words it'd make a new function to disconnect. lightpower26 399 — 8y

Answer this question