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

Why dosent free cam script work online?

Why dosent this script work in Online but works in Play mode in roblox studio cant really tell why this is happening so im asking you people. So i want it to be so if you click the gui button then you will be in free cam mode. This was the only thing i could think of to make it.

Script.

player = script.Parent.Parent.Parent.Parent
character = player.Character
torso= character.Torso
head = character.Head
-- these just help if you want to kill yourself or something
clicked = false
function OB1D(mouse)

end

script.Parent.MouseButton1Down:connect(function()
	script.Parent.Parent.Parent.FreeCamGui:Destroy()
end)

script.Parent.MouseButton1Down:connect(function()
	cam = game.Workspace.CurrentCamera
	cam.CameraType = "Fixed"
	cam.CameraSubject = nil
	game.Players.LocalPlayer.Character = nil
	mouse.Button1Down:connect(function () OB1D(mouse) end)
	mouse.Button1Up:connect(Up)
end)

1 answer

The Error

One of the biggest issues is, Works in Studio, not in Game. There are multiple reasons behind this. One of the simplest ones could be that you used the incorrect script. Normal Scripts are used in ServerStorage, Workspace, etc. Normal scripts cannot be used to modify GUIs or Cameras. LocalScripts are used in characters, players, and GUIs. LocalScripts cannot be used in any other place. This is the only one I can think of after briefly examining the script. (Tip, If you use the whole script.Parent.Parent.Parent.... thing for players, it looks really unorganized, also use locals whenever using variables. It looks a lot cleaner as well. There are some occasions where you don't need to use locals, and that's whenever you need to use a variable, that you defined in a function, in other functions.)

If you still don't understand, or I gave the incorrect solution...

There's an amazing blogpost by the Site owner, Evaera.

Finished script EDITED

local player = game.Players.LocalPlayer 
repeat wait() until player.Character
local character = player.Character
local torso= character:WaitForChild('Torso')
local head = character:WaitForChild('Head')
local clicked = false

--[[function OB1D(mouse)

end]]--

script.Parent.MouseButton1Down:connect(function()
    script.Parent.Parent.Parent.FreeCamGui:Destroy()
end)

script.Parent.MouseButton1Down:connect(function()
    cam = game.Workspace.CurrentCamera
    cam.CameraType = "Fixed"
    cam.CameraSubject = nil
    character = nil --I'm like, 90% sure this would mess something up.
    mouse.Button1Down:connect(function ()
        -- OB1D(mouse) --Empty function
      end)
    --mouse.Button1Up:connect(Up) --Nil function
end)

If this helped you, then please accept the answer. If not, then please tell me what went wrong and I'll do my best to help you.

6 comments

0

It still dosent work in online

1

What is the output? (Press F9)

0

Torso is not a valid member of model.

0

Fixed.

0

Now the camera just stays in the same spot.

0

Okay, now all you need to do is change the position whenever a button is pushed. That's entirely different and I have successfully answered your question, so please accept my answer.

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