Skip to content

Instantly share code, notes, and snippets.

View RobertCodez's full-sized avatar
💻
Scripting In Lua

Depper RobertCodez

💻
Scripting In Lua
View GitHub Profile
@RobertCodez
RobertCodez / GridUpgrade.lua
Created April 14, 2023 14:16
Grid Upgrader Script
for _,v in pairs(game.Workspace.Grid:GetChildren()) do
v.ClickDetector.MouseClick:Connect(function(player)
if v:GetAttribute("Occupied") == "YES" then
local BuildingToUpgrade
for _,building in pairs(game.Workspace.Buildings:GetChildren()) do
if tonumber(building:GetAttribute("CorrespondingGridNumber")) == tonumber(v.Name) then
print("Corresponding building found")
@RobertCodez
RobertCodez / GridPlacement.lua
Created April 14, 2023 14:14
Grid Based placement system
local SoundService = game:GetService("SoundService")
local function destroyv(player,v)
if v:FindFirstChild("SelectionBox") then
v:FindFirstChildOfClass("SelectionBox"):Destroy()
end
if v:FindFirstChild(tostring(player.TempVal.SelectedObject.Value)) then
v:FindFirstChild(tostring(player.TempVal.SelectedObject.Value)):Destroy()
end
@RobertCodez
RobertCodez / Loadout.lua
Created February 7, 2022 14:50
A tool lodout for when the player joins
local ToolFolder = game.ReplicatedStorage.Tools
local Template = script.Template
local player = game.Players.LocalPlayer
local PageIndex = 1
local Pages = {
[1] = "Primary",
[2] = "Secondary",
[3] = "Melee",
[4] = "Misc"
}
@RobertCodez
RobertCodez / Transparency.lua
Created July 30, 2021 17:13
Player Transparency
local rStorage = game:GetService("ReplicatedStorage")
local rEvents = rStorage:WaitForChild("RemoteEvents")
local plr = game.Players.LocalPlayer
rEvents.HidePlayers.OnClientEvent:Connect(function()
for i,v in pairs(game.Players:GetChildren()) do
if v.Name ~= plr.Name then
local char = workspace:WaitForChild(v.Name)
for i,part in pairs(char:GetDescendants()) do
@RobertCodez
RobertCodez / sword.lua
Created July 30, 2021 17:07
Sword Script | Weapons
local tool = script.Parent
local idleAnim = script:WaitForChild("Idle")
local idleAnimTrack
local swingAnim = script:WaitForChild("Swing")
local swingAnimTrack
local count = 1
local slashSound = script:WaitForChild("SlashSound")
local sheathSound = script:WaitForChild("SheathSound")
@RobertCodez
RobertCodez / NPC.lua
Created July 30, 2021 17:06
NPC Chat Script
local gui = script.Parent
local text = gui.TextBackground.Text
local op1 = gui.TextBackground.Option1
local op2 = gui.TextBackground.Option2
local distanceToUI = 7
local playerd = game.Players.LocalPlayer
@RobertCodez
RobertCodez / Object Datastore.lua
Last active April 14, 2023 14:18
Object Oriented Datastore
local myData = game:GetService("DataStoreService"):GetDataStore("yeah")
game.Players.PlayerAdded:Connect(function(plr)
local ChickensOwned = Instance.new("Folder", plr)
ChickensOwned.Name = "ChickensOwned"
pcall(function()
local data = myData:GetAsync(plr.UserId)
for _,v in pairs(data) do
local chicken = Instance.new("StringValue", ChickensOwned)
chicken.Name = "Chicken"
@RobertCodez
RobertCodez / Saver.lua
Created July 30, 2021 17:01
Stage Saver
local myData = game:GetService("DataStoreService"):GetDataStore("CodezStore")
game.Players.PlayerAdded:Connect(function(plr)
local StagesOwned = Instance.new("Folder", plr)
StagesOwned.Name = "StagesOwned"
pcall(function()
local data = myData:GetAsync(plr.UserId)
for _, v in pairs(data) do
local newStage = Instance.new("BoolValue", plr.StagesOwned)
newStage.Name = v
@RobertCodez
RobertCodez / Fighting.lua
Created July 30, 2021 16:59
Pet Hatching, and Chicken fighting in Arena's
local plr = game.Players.LocalPlayer
local cam = workspace.CurrentCamera
local TS = game:GetService("TweenService")
local arenaInstructions = {"Welcome to the Wide Arena!", "Your chickens will battle against everybody else's Chicken!", "The winner will win a prize of 500 Coins!", "May the best Chicken win!"}
local impossible = false
local function cameraShake()
for i = 1, 20 do
@RobertCodez
RobertCodez / Proximity-prompts.lua
Created July 30, 2021 16:57
Proximity Prompts
local ProximityPromptService = game:GetService("ProximityPromptService")
local function onPromptTriggered(promptObject, player)
end
local function onPromptHoldBegan(promptObject, player)
end