local UIS = game:GetService("UserService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
would it be possible to write all of this once into one single script and just refrence that script?
if so please let me know how
You can put it all in a module script and reference the services from there.
For the character & humanoids, however, you can use a function to retrieve their references, similar to a “getter” method in OOP. Inside the module script, you can make a function like the following:
function module.GetCharacter() do
return ...
end
function module.GetHumanoid() do
return ...
end