Help with a script

Hey everyone, so I have no experience scripting, so if anyones willing to help me that’d be appreciated!

So, i have a script for a hand to system for my cafe game, and I have to add a mechanisim to toggle it with a keybind

Script:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Common = ReplicatedStorage:WaitForChild("Common")
local Modules = {}
local _UI
local Bindable = Instance.new("BindableFunction")

local function Invoke(Type)
	if _UI then
		if Type == "Toggle" then
			_UI.Properties.Toggled = not _UI.Properties.Toggled
			_UI:Deploy()
		end
	end
end

local function Init()
	local Container = Instance.new("ScreenGui")
	_UI = Modules.Cook.new(Container)
	Container.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
	Bindable.Parent = script
	Container.Parent = Players.LocalPlayer.PlayerGui
	
	Bindable.OnInvoke = Invoke
	
	_UI:Deploy()
end

for _, v in pairs(Common:GetChildren()) do
	if v:IsA("ModuleScript") then
		Modules[v.Name] = require(v)
	end
end

Init()

If someone could help me with this that would be appreciated! Thanks :slight_smile:

You can use either these

UserInputService

ContextActionService

Thanks! Just curious, where would I put the script?

A Local script, they can only go in the following: StarterGui, StarterPack, StarterCharacterScripts, StarterPlayerScripts, ReplacedStorge, you probably don’t want it in replacedStorge, so you probably want to put your script StarterPlayersScripts.

Looks like someone answered before me, but you should probably title your posts better too.

haha, sorry i was doing it from a phone and made it quickly so i was being lazy, sorry bout that

1 Like