Help Needed: Making a My Code Functional in a LocalScript

I have a script for a cooking system that was originally intended to run on the server. I now want to convert this script to run fully on the client side as a localscript.

Overview
:black_small_square: Picking up and placing lentils (Toggling transparency / moving positions via tween to simulate the pots moving)
:black_small_square: ProximityPrompt disabling itself and enabling the next prompt to simulate the cooking ‘process’

I want to have It where that each player’s interactions are handled locally to keep other players from interfering with one’s cooking.

The Issue
I’ve tried adapting the script to work on the client side, but the entirety of the script doesn’t function. (No logs shown in console/output regarding to this)

---- //// COOKING SYSTEM BY @GAMINGBETA2323

local player = game.Players.LocalPlayer
local TweenService = game:GetService("TweenService")

local CookingSystem = workspace.CookingSystem

--- // LENTIL
local PLProx = CookingSystem.Lentil.PlaceLentil.PickupProx
local FaucetProx = CookingSystem.Lentil.Faucet.FaucetProx
local LentilCookProx = CookingSystem.Lentil.PotActivator.CookProx
local LentilGiveProx = CookingSystem.Lentil.PotGiver.GiveProx
local TrayProx = CookingSystem.Lentil.TrayPlaceLentil.TrayProx

local TrayDal = CookingSystem.Lentil.TrayPlaceLentil.Tray.Daal
local LentilProx = CookingSystem.LentilPart.LentilProx
local SFX = CookingSystem.LentilPart.SFX

-- Handle LentilProx Trigger
LentilProx.Triggered:Connect(function()
    SFX:Play()
    LentilProx.Enabled = false
    PLProx.Enabled = true
end)

-- PLACE LENTIL
local DropSFX = CookingSystem.Lentil.PlaceLentil.DropSFX
local LidSFX = CookingSystem.Lentil.PlaceLentil.LidSFX
local Lid = CookingSystem.Lentil.PlaceLentil.Pot.Lid
local Daal = CookingSystem.Lentil.PlaceLentil.Pot.Daal
local BagOpen = CookingSystem.Lentil.PlaceLentil.BagOpen

-- TWEEN LID
Lid.Position = Vector3.new(-161.377, 4.992, -464.947)
local Duration = 0.25
local goal = {Position = Vector3.new(-161.749, 4.992, -464.947)}

local tweenInfo = TweenInfo.new(
    Duration,                -- Time 
    Enum.EasingStyle.Linear, -- EasingStyle
    Enum.EasingDirection.Out -- EasingDirection
)
local moveTray = TweenService:Create(Lid, tweenInfo, goal)

-- TWEEN DAAL
Daal.Size = Vector3.new(0.001, 0.823, 1.009)
local DalDuration = 3.47
local Dalgoal = {Size = Vector3.new(0.343, 0.823, 1.009)}

local daltweenInfo = TweenInfo.new(
    DalDuration,                -- time 
    Enum.EasingStyle.Linear, -- easingstyle
    Enum.EasingDirection.Out -- easingdirection
)
local DalFall = TweenService:Create(Daal, daltweenInfo, Dalgoal)

PLProx.Triggered:Connect(function()
    PLProx.Enabled = false
    moveTray:Play()
    LidSFX:Play()
    wait(0.5)
    BagOpen:Play()
    wait(1)
    DropSFX:Play()
    Daal.Transparency = 0
    DalFall:Play() -- TWEEN
    FaucetProx.Enabled = true
end)

-- / ADD WATER
local FaucetPot = CookingSystem.Lentil.Faucet.Pot.Object_10
local PanPlace = CookingSystem.Lentil.Faucet.PanPlace
local FaucetSFX = CookingSystem.Lentil.Faucet.FaucetSFX
local Water = CookingSystem.Lentil.Faucet.Water
local Daal2 = CookingSystem.Lentil.Faucet.Pot.Daal

-- TWEEN DAL ON SINK
Daal2.Size = Vector3.new(0.343, 0.823, 1.009)
local DalDuration = 13
local Dalgoal2 = {Size = Vector3.new(0.49, 0.823, 1.009)}

local DaalWater = TweenService:Create(Daal2, daltweenInfo, Dalgoal2)

FaucetProx.Triggered:Connect(function()
    FaucetProx.Enabled = false
    FaucetPot.Transparency = 0
    Daal2.Transparency = 0
    PanPlace:Play()
    Lid.Position = Vector3.new(-161.377, 4.992, -464.947)
    wait(0.4)
    FaucetSFX:Play()    
    Daal.Transparency = 1
    Daal.Size = Vector3.new(0.001, 0.823, 1.009)
    Water.Enabled = true
    DaalWater:Play() -- TWEEN
    wait(13)
    Water.Enabled = false
    LentilCookProx.Enabled = true
end)

-- // COOK
local FaucetPot = CookingSystem.Lentil.Faucet.Pot.Object_10

local LentilFireLight = CookingSystem.Lentil.PotActivator.PointLight
local LentilPlaceSFX = CookingSystem.Lentil.PotActivator.PanPlace
local LentilOnSFX = CookingSystem.Lentil.PotActivator.OnSFX
local LentilBoilSFX = CookingSystem.Lentil.PotActivator.BoilSFX
local FireSFX = CookingSystem.Lentil.PotActivator.FireSFX
local Timer = CookingSystem.Lentil.PotActivator.Timer

local stovePot = CookingSystem.Lentil.Stovepot.Object_10
local StoveDaal = CookingSystem.Lentil.Stovepot.Daal
local Smoke = StoveDaal.Smoke
local FaucetDal = CookingSystem.Lentil.Faucet.Pot.Daal

LentilCookProx.Triggered:Connect(function()
    LentilCookProx.Enabled = false
    stovePot.Transparency = 0
    StoveDaal.Transparency = 0
    FaucetPot.Transparency = 1
    FaucetDal.Transparency = 1
    Daal2.Size = Vector3.new(0.343, 0.823, 1.009)
    LentilPlaceSFX:Play()
    wait(0.5)
    LentilOnSFX:Play()
    FireSFX:Play()
    LentilFireLight.Enabled = true
    wait(9)
    LentilBoilSFX:Play()
    Smoke.Enabled = true
    wait(9.5)
    Timer:Play()
    LentilGiveProx.Enabled = true
    LentilFireLight.Enabled = false
end) 

-- // POT GIVER
local PickupSFX = CookingSystem.Lentil.PotGiver.PickupSFX

LentilGiveProx.Triggered:Connect(function()
    LentilGiveProx.Enabled = false
    TrayProx.Enabled = true
    Smoke.Enabled = false
    stovePot.Transparency = 1
    StoveDaal.Transparency = 1

    PickupSFX:Play()
    Timer:Pause()
end)

-- // TRAY PLACER
local PotPlace = CookingSystem.Lentil.TrayPlaceLentil.PanPlace
local PlaceSFX = CookingSystem.Lentil.TrayPlaceLentil.PanPlace

TrayProx.Triggered:Connect(function()
    PlaceSFX:Play()
    TrayProx.Enabled = false
    LentilProx.Enabled = true
    TrayDal.Transparency = 0
    
    wait(25)
    TrayDal.Transparency = 1
end)

Have you tried placing print statements around the code to see if it unexpectedly stops anywhere? Try placing them at the start of the prompt triggers and see if they are fired in the first place.

2 Likes

Yes, I’ve tried that but no print logs were shown in the output or console.

bandicam 2024-08-10 18-00-30-138
Should I move this to ReplicatedFirst instead?

ClientScripts will only run in GUIs inside of PlayerGUI, StarterPlayerScripts and StarterCharacterScripts, so it depends where that “CookingSystem” folder is which I presume is in ReplicatedStorage, if so you need to move the handler into StarterPlayerScripts for it to actually run.

I would also like to add that local scripts can also be run in replicatedFirst. It is also worth noting separately that the local script can be run in workspace, for this you need to first create a server script, and then change its RunContext to client.
image

2 Likes

I see, moving it to StarterPlayerScripts was what I needed to do to make my script work. Thank you very much.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.