Help, suggestion and feedback on my horror game mechanics

Hello, my name is Fizzavocadoo and I am a builder and I am a new member of dev forum. So last week I have decided to make a story and horror game with a condition that players can only see the ghost when a camera tool is equip.

Yesterday I have try to script the camera with my little knowledge of scripting and I got not bad result ( You can go see the video below). but there’s some issues.
Firstly, The FOV when I equip the camera is not working and that’s the issue so far but I need some of your suggestion on how I can make it smoother and more recording like effects. I want to achieve something like a security camera opening animation from the game Fnaf. This is just the prototype and I will add more animation and effects soon if I can. so please try to give me some feedback and some suggestion.

I wrote the script by myself with the help of my little knowledge of scripting and Youtube tutorials. I also try to find some tutorials to fix my FOV problem but still can’t get it working here is the script.

Tool = script.Parent

local function GhostAppear()
    local GhostH = game.Workspace.Ghost.Head
    local GhostRA = game.Workspace.Ghost["Right Arm"]
    local GhostLA = game.Workspace.Ghost["Left Arm"]
    local GhostRL = game.Workspace.Ghost["Right Leg"]
    local GhostLL = game.Workspace.Ghost["Left Leg"]
    local GhostT = game.Workspace.Ghost.Torso

    GhostH.Transparency = 0
    GhostRA.Transparency = 0
    GhostLA.Transparency = 0
    GhostRL.Transparency = 0
    GhostLL.Transparency = 0
    GhostT.Transparency = 0
end

local function GhostDisappear()
    local GhostH = game.Workspace.Ghost.Head
    local GhostRA = game.Workspace.Ghost["Right Arm"]
    local GhostLA = game.Workspace.Ghost["Left Arm"]
    local GhostRL = game.Workspace.Ghost["Right Leg"]
    local GhostLL = game.Workspace.Ghost["Left Leg"]
    local GhostT = game.Workspace.Ghost.Torso

    GhostH.Transparency = 1
    GhostRA.Transparency = 1
    GhostLA.Transparency = 1
    GhostRL.Transparency = 1
    GhostLL.Transparency = 1
    GhostT.Transparency = 1
end

local function ColorCorrection1()
    game.Lighting.ColorCorrection.Enabled = true
end

local function ColorCorrection2()
    game.Lighting.ColorCorrection.Enabled = false
end

function OnEquip()
    local FOV = 50
    local character = Tool.Parent
    local Player = game.Players:GetPlayerFromCharacter(character)
    Gui = script.Parent.Gui:Clone()
    Gui.Parent = Player.PlayerGui
    GhostAppear()
    ColorCorrection1()
    game.Workspace.Camera.FieldOfView = FOV
    wait(0.1)
    script.Parent.Handle.Transparency = 1
end

function OnUnequip()
    local FOV = 50
    Gui:Destroy()
    GhostDisappear()
    ColorCorrection2()
    game.Workspace.Camera.FieldOfView = FOV
    wait(0.1)
    script.Parent.Handle.Transparency = 0
end

Tool.Equipped:Connect(OnEquip)
Tool.Unequipped:Connect(OnUnequip)

I’m sorry if the script I wrote is a bit trash but it works.

3 Likes

Is this code located in a LocalScript? Cause otherwise, you are setting the FieldOfView of the server’s camera. This script should be a LocalScript, since you want the Ghost behaviour to be client-sided (player specific). The same goes for the FieldOfView effect. You can read more about the client-server model here: Client-Server Model | Roblox Creator Documentation.

2 Likes

local function GhostAppear()
    local GhostH = game.Workspace.Ghost.Head
    local GhostRA = game.Workspace.Ghost["Right Arm"]
    local GhostLA = game.Workspace.Ghost["Left Arm"]
    local GhostRL = game.Workspace.Ghost["Right Leg"]
    local GhostLL = game.Workspace.Ghost["Left Leg"]
    local GhostT = game.Workspace.Ghost.Torso

    GhostH.Transparency = 0
    GhostRA.Transparency = 0
    GhostLA.Transparency = 0
    GhostRL.Transparency = 0
    GhostLL.Transparency = 0
    GhostT.Transparency = 0
end

local function GhostDisappear()
    local GhostH = game.Workspace.Ghost.Head
    local GhostRA = game.Workspace.Ghost["Right Arm"]
    local GhostLA = game.Workspace.Ghost["Left Arm"]
    local GhostRL = game.Workspace.Ghost["Right Leg"]
    local GhostLL = game.Workspace.Ghost["Left Leg"]
    local GhostT = game.Workspace.Ghost.Torso

    GhostH.Transparency = 1
    GhostRA.Transparency = 1
    GhostLA.Transparency = 1
    GhostRL.Transparency = 1
    GhostLL.Transparency = 1
    GhostT.Transparency = 1
end

This seems very tedious, cant you just get all the children to the ghost model through a for loop and set its transparency from there to 0 or 1?

2 Likes

The script is located in the tool also the game will be for only 1 player so I think it doesn’t really matter but if this was for mutiplayer I would have to fix a lot of things

1 Like

I don’t really know what I am doing because I don’t script.

1 Like

What I mean is getting everything that is in the ghost model, and then if it is a part, set its transparency to whatever you like. For example:

local GhostModel = workspace.Ghost -- get the ghost model

local function GhostAppear()
for _,Part in pairs(GhostModel:GetChildren()) do 
    -- "Part" is everything parented to the ghost model
    -- "GhostModel:GetChildren()" gets a table with everything parented to the model in it

    if Part:IsA("BasePart") then  -- If the child in the model is a part, change its transparency
        Part.Transparency = 0
    end
end

And then for the ghost to disappear, just do the exact same thing but Part.Transparency = 1.

2 Likes

There are 3 script classes: Script (server-sided), LocalScript (client-sided) and ModuleScript (can be both). I am pretty sure that you are using a Script, rather than a LocalScript (which is the one you need for this case as I explained earlier).

This is what they look like in the explorer:

afbeelding

You need the ‘LocalScript’.

2 Likes

You could also make the Record Icon and text blink, every second

2 Likes