Untitled

Anonymous
Plain Text
09/27/2025 4:22 AM
7.8 KB
17
Indexable
Never
-- ServerScriptService > GameSetup.lua
-- One script to build everything: Leaderboard, ColorPad, Sword, Welcome GUI

local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")

---------------------------------------------------------------------
-- 1) Leaderboard setup
---------------------------------------------------------------------
Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new("Folder")
        leaderstats.Name = "leaderstats"
            leaderstats.Parent = player
            
                local coins = Instance.new("IntValue")
                    coins.Name = "Coins"
                        coins.Value = 0
                            coins.Parent = leaderstats
                            
                                local kills = Instance.new("IntValue")
                                    kills.Name = "Kills"
                                        kills.Value = 0
                                            kills.Parent = leaderstats
                                            end)

                                            ---------------------------------------------------------------------
                                            -- 2) Color-changing Part
                                            ---------------------------------------------------------------------
                                            local pad = Instance.new("Part")
                                            pad.Name = "ColorPad"
                                            pad.Size = Vector3.new(6,1,6)
                                            pad.Anchored = true
                                            pad.Position = Vector3.new(0, 3, 0)
                                            pad.BrickColor = BrickColor.new("Bright blue")
                                            pad.Parent = workspace

                                            local padDebounce = {}

                                            pad.Touched:Connect(function(other)
                                                local char = other.Parent
                                                    if not char then return end
                                                        local player = Players:GetPlayerFromCharacter(char)
                                                            if not player then return end
                                                            
                                                                local uid = player.UserId
                                                                    if padDebounce[uid] then return end
                                                                        padDebounce[uid] = true
                                                                        
                                                                            local original = pad.BrickColor
                                                                                pad.BrickColor = BrickColor.Random()
                                                                                    task.wait(0.4)
                                                                                        pad.BrickColor = original
                                                                                        
                                                                                            local stats = player:FindFirstChild("leaderstats")
                                                                                                if stats and stats:FindFirstChild("Coins") then
                                                                                                        stats.Coins.Value += 5
                                                                                                            end
                                                                                                            
                                                                                                                task.wait(1)
                                                                                                                    padDebounce[uid] = nil
                                                                                                                    end)

                                                                                                                    ---------------------------------------------------------------------
                                                                                                                    -- 3) Simple Sword Tool
                                                                                                                    ---------------------------------------------------------------------
                                                                                                                    local tool = Instance.new("Tool")
                                                                                                                    tool.Name = "SimpleSword"
                                                                                                                    tool.RequiresHandle = true
                                                                                                                    tool.CanBeDropped = true

                                                                                                                    local handle = Instance.new("Part")
                                                                                                                    handle.Name = "Handle"
                                                                                                                    handle.Size = Vector3.new(1,4,1)
                                                                                                                    handle.BrickColor = BrickColor.new("Really black")
                                                                                                                    handle.CanCollide = false
                                                                                                                    handle.Parent = tool

                                                                                                                    tool.Parent = game.StarterPack

                                                                                                                    local DAMAGE = 25
                                                                                                                    local HIT_COOLDOWN = 0.5
                                                                                                                    local recentHits = {}

                                                                                                                    local function onTouched(hit, attackerPlayer)
                                                                                                                        local humanoid = hit.Parent and hit.Parent:FindFirstChildWhichIsA("Humanoid")
                                                                                                                            if not humanoid then
                                                                                                                                    local ancestor = hit:FindFirstAncestorWhichIsA("Model")
                                                                                                                                            if ancestor then
                                                                                                                                                        humanoid = ancestor:FindFirstChildWhichIsA
Editor is loading...
Leave a Comment