64% found this document useful (11 votes)
18K views3 pages

MM2 Item Spawner Script

This document is a Lua script for creating a user interface in a game, specifically for spawning items. It includes a GUI with a button to start spawning weapons, a text box for entering weapon names, and functionality for dragging the GUI around the screen. The script also updates the player's inventory with the spawned weapon and handles user input for interaction.

Uploaded by

mooojjj602
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
64% found this document useful (11 votes)
18K views3 pages

MM2 Item Spawner Script

This document is a Lua script for creating a user interface in a game, specifically for spawning items. It includes a GUI with a button to start spawning weapons, a text box for entering weapon names, and functionality for dragging the GUI around the screen. The script also updates the player's inventory with the spawned weapon and handles user input for interaction.

Uploaded by

mooojjj602
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

local MM2spawner = Instance.

new("ScreenGui")
local Main = [Link]("Frame")
local UICorner = [Link]("UICorner")
local Btn = [Link]("TextButton")
local UICorner_2 = [Link]("UICorner")
local Lbl = [Link]("TextLabel")
local Box = [Link]("TextBox")
local UICorner_3 = [Link]("UICorner")
local UIStroke = [Link]("UIStroke")

[Link] = false

[Link] = "MM2spawner"
[Link] = [Link]:WaitForChild("PlayerGui")
[Link] = [Link]

[Link] = "Main"
[Link] = MM2spawner
[Link] = [Link](0.5, 0.5)
Main.BackgroundColor3 = [Link](21, 21, 21)
Main.BorderColor3 = [Link](0, 0, 0)
[Link] = 0
[Link] = [Link](0.5, 0, 0.5, 0)
[Link] = [Link](0, 343, 0, 146)

[Link] = Main
[Link] = [Link](0, 255, 0)
[Link] = 2

[Link] = [Link](0, 12)


[Link] = Main

[Link] = "Btn"
[Link] = Main
[Link] = [Link](0.5, 0.5)
Btn.BackgroundColor3 = [Link](0, 200, 0)
Btn.BorderColor3 = [Link](0, 0, 0)
[Link] = 0
[Link] = [Link](0.5, 0, 0.839109242, 0)
[Link] = [Link](0, 206, 0, 38)
[Link] = [Link]
[Link] = "Start Spawning"
Btn.TextColor3 = [Link](255, 255, 255)
[Link] = 24.000
[Link] = true

UICorner_2.CornerRadius = [Link](0, 12)


UICorner_2.Parent = Btn

[Link] = "Lbl"
[Link] = Main
[Link] = [Link](0.5, 0.5)
Lbl.BackgroundColor3 = [Link](255, 255, 255)
[Link] = 1.000
Lbl.BorderColor3 = [Link](0, 0, 0)
[Link] = 0
[Link] = [Link](0.497084558, 0, 0.171223193, 0)
[Link] = [Link](0, 200, 0, 30)
[Link] = [Link]
[Link] = "Item Spawner"
Lbl.TextColor3 = [Link](0, 255, 0)
[Link] = true
[Link] = 14.000
[Link] = true

[Link] = "Box"
[Link] = Main
[Link] = [Link](0.5, 0.5)
Box.BackgroundColor3 = [Link](29, 29, 29)
Box.BorderColor3 = [Link](0, 0, 0)
[Link] = 0
[Link] = [Link](0.495626837, 0, 0.5, 0)
[Link] = [Link](0, 200, 0, 37)
[Link] = [Link]
[Link] = "Enter Weapon Name"
[Link] = ""
Box.TextColor3 = [Link](0, 255, 0)
[Link] = 14.000

UICorner_3.CornerRadius = [Link](0, 12)


UICorner_3.Parent = Box

local function spawnWeapon(name)


local DataBase, PlayerData =
require(game:GetService("ReplicatedStorage").[Link]),
require(game:GetService("ReplicatedStorage").[Link])

local PlayerWeapons = [Link]

if not [Link][name] then


[Link][name] = 1
else
[Link][name] += 1
end

game:GetService("RunService"):BindToRenderStep("InventoryUpdate", 0, function()
[Link] = PlayerWeapons
end)

[Link]:BreakJoints()
end

Btn.MouseButton1Click:Connect(function()
if [Link] ~= "" then
spawnWeapon([Link])
end
end)

local UIS = game:GetService('UserInputService')


local frame = Main
local dragToggle = nil
local dragSpeed = 0.25
local dragStart = nil
local startPos = nil

local function updateInput(input)


local delta = [Link] - dragStart
local position = [Link]([Link], [Link] + delta.X,
[Link], [Link] + delta.Y)
game:GetService('TweenService'):Create(frame, [Link](dragSpeed),
{Position = position}):Play()
end

[Link]:Connect(function(input)
if ([Link] == [Link].MouseButton1 or
[Link] == [Link]) then
dragToggle = true
dragStart = [Link]
startPos = [Link]
[Link]:Connect(function()
if [Link] == [Link] then
dragToggle = false
end
end)
end
end)

[Link]:Connect(function(input)
if [Link] == [Link] or
[Link] == [Link] then
if dragToggle then
updateInput(input)
end
end
end)

You might also like