#How do I convert this localscript into a regular script

1 messages · Page 1 of 1 (latest)

agile yarrow
#

Hi! I have a localscript that is meant to make certain parts visible when a player clicks on it with a certain tool. This was originally a localscript, but I have to change it to a regular script, as it was only showing up for that specific player. I moved it from StarterPlayerScripts to StarterCharacterScripts, but it is (as expected) no longer working. How would I go about changing this to a regular script rather than a local script (it is currently in a middle limbo area). (Also ignore the weird names, I copied it from a different script in my game and couldn't be asked to change the names).

#
local UserInputService = game:GetService("UserInputService")
local LocalPlayer = script.Parent

local PADLOCK_PART_NAME = "JacobClick"
local BLUE_KEY_NAME = "Michael's Safe Contents"
local clickdetector = workspace.JacobClick.ClickDetector

local function getEquippedTool()
    local character = LocalPlayer.Character
    if character then
        for _, child in character:GetChildren() do
            if child:IsA("Tool") and child.Name == BLUE_KEY_NAME then
                return child
            end
        end
    end
    return nil
end

local function openDiaryGui()
    local MichaelPhotos = workspace.MichaelPhotos
    local Photo = MichaelPhotos.Photo
    local Poster = MichaelPhotos.Poster
    local henryletter = MichaelPhotos.henryletter
    local henryphoto = MichaelPhotos.henryphoto
    local henrypolaroid = MichaelPhotos.henrypolaroid
    local heart1 = Photo.Heart1
    local heart2 = Photo.Heart2
    local heart3 = Photo.Heart3
    local base = Photo.Base
    local henryandmichael = Photo.henryandmichael
    local poster1 = Poster.poster1
    local poster2 = Poster.Union
    local decal1 = poster1.Decal1
    local decal2 = poster1.Decal2
    local decal3 = poster1.Decal3
    local decal4 = poster1.Decal4

    henryletter.Transparency = 0
    henryphoto.Transparency = 0
    henrypolaroid.Transparency = 0
    henryletter.Decal.Transparency = 0
    henryphoto.Decal.Transparency = 0
    henrypolaroid.Decal.Transparency = 0
    heart1.Transparency = 0
    heart2.Transparency = 0
    heart3.Transparency = 0
    base.Transparency = 0
    henryandmichael.Transparency = 0
    henryandmichael.Decal.Transparency = 0
    poster1.Transparency = 0
    poster2.Transparency = 0
    decal1.Transparency = 0
    decal2.Transparency = 0
    decal3.Transparency = 0
    decal4.Transparency = 0
end```
#
    local target = clickdetector.Target
    if target and target.Name == PADLOCK_PART_NAME then
        local equippedTool = getEquippedTool()
        if equippedTool then
            openDiaryGui()
        end
    end
end)```
#

I have to post the script in 2 parts cuz it's too long

eager ravine
#

wow uh

#

you should really clean that up

#

it hurts to read

#

you can convert local to script with remoteevents or just copy paste it if u need the entire script to swap over.

agile yarrow
eager ravine
#

still could clean it up

#

easier to write as well