Pinkstack/roblox-luau-corpus-text huggingface dataset:
--[[ Touch Events ]]

--
UserInputService.Changed:connect(function(property)
	if property == 'ModalEnabled' then
		IsModalEnabled = UserInputService.ModalEnabled

		if lastInputType == Enum.UserInputType.Touch then
			if ControlState.Current == ControlModules.Touch and IsModalEnabled then
				ControlState:SwitchTo(nil)
			elseif ControlState.Current == nil and not IsModalEnabled then
				ControlState:SwitchTo(ControlModules.Touch)
			end
		end
	end
end)

if BindableEvent_OnFailStateChanged then
	BindableEvent_OnFailStateChanged.Event:connect(function(isOn)
		if lastInputType == Enum.UserInputType.Touch and ClickToMoveTouchControls then
			if isOn then
				ControlState:SwitchTo(ClickToMoveTouchControls)
			else
				ControlState:SwitchTo(nil)
			end
		end
	end)
end

local switchToInputType = function(newLastInputType)
	lastInputType = newLastInputType
	
	if lastInputType == Enum.UserInputType.Touch then
				ControlState:SwitchTo(ControlModules.Touch)
	elseif lastInputType == Enum.UserInputType.Keyboard or
			lastInputType == Enum.UserInputType.MouseButton1 or
			lastInputType == Enum.UserInputType.MouseButton2 or
			lastInputType == Enum.UserInputType.MouseButton3 or
			lastInputType == Enum.UserInputType.MouseWheel or
			lastInputType == Enum.UserInputType.MouseMovement  then
				ControlState:SwitchTo(ControlModules.Keyboard)
	elseif lastInputType == Enum.UserInputType.Gamepad1 or
			lastInputType == Enum.UserInputType.Gamepad2 or
			lastInputType == Enum.UserInputType.Gamepad3 or
			lastInputType == Enum.UserInputType.Gamepad4 then
				ControlState:SwitchTo(ControlModules.Gamepad)
	end
end

if IsTouchDevice then
	createTouchGuiContainer()
end

MasterControl:Init()

UserInputService.GamepadDisconnected:connect(function(gamepadEnum)
	local connectedGamepads = UserInputService:GetConnectedGamepads()
	if #connectedGamepads > 0 then return end
	
	if UserInputService.KeyboardEnabled then
		ControlState:SwitchTo(ControlModules.Keyboard)
	elseif IsTouchDevice then
		ControlState:SwitchTo(ControlModules.Touch)
	end
end)

UserInputService.GamepadConnected:connect(function(gamepadEnum)
	ControlState:SwitchTo(ControlModules.Gamepad)
end)

switchToInputType(UserInputService:GetLastInputType())
UserInputService.LastInputTypeChanged:connect(switchToInputType)
-- ROBLOX upstream: https://github.com/facebook/jest/blob/v27.4.7/packages/test-utils/src/alignedAnsiStyleSerializer.ts
-- /**
--  * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
--  *
--  * This source code is licensed under the MIT license found in the
--  * LICENSE file in the root directory of this source tree.
--  */



local CurrentModule = script.Parent
local Packages = CurrentModule.Parent

local ansiRegex = require(Packages.PrettyFormat).plugins.ConvertAnsi.ansiRegex
-- Load the SoundDispatcher script into Studio


local soundDispatcherName = "SoundDispatcher"
local ServerScriptService = game:GetService("ServerScriptService")

local function LoadScript(name, parent)
	local originalModule = script.Parent:WaitForChild(name)
	local script = Instance.new("Script")
	script.Name = name
	script.Source = originalModule.Source
	script.Parent = parent
	return script
end

local function Install()
	local soundDispatcherArchivable = true
	local SoundDispatcher = ServerScriptService:FindFirstChild(soundDispatcherName)
	if not SoundDispatcher then
		soundDispatcherArchivable = false
		SoundDispatcher = LoadScript(soundDispatcherName, ServerScriptService)
	end

	if not ServerScriptService:FindFirstChild(soundDispatcherName) then
		local SoundDispatcherCopy = SoundDispatcher:Clone()
		SoundDispatcherCopy.Archivable = false
		SoundDispatcherCopy.Parent = ServerScriptService
	end

	SoundDispatcher.Archivable = soundDispatcherArchivable
end

return Install
-- ROBLOX deviation predefine variables


local getMatchingKeyPaths, replaceKeyPathWithValue, getPath

export type Template = Record<string, any>
export type Templates = Array<Template>
export type Headings = Array<string>

local function interpolateVariables(title: string, template: Template, index: number): string
	return Array.reduce(
		Array.reduce(Object.keys(template), getMatchingKeyPaths(title), {}), -- aka flatMap
		replaceKeyPathWithValue(template),
		title
	):gsub(
		"%$#", -- ROBLOX deviation: escaped string
		tostring(index),
		1
	)
end
exports.interpolateVariables = interpolateVariables

function getMatchingKeyPaths(title: string)
	return function(matches: Headings, key: string)
		return Array.concat(
			matches,
			(function()
				local ref = {}
				for match in title:gmatch(("%%$%s[%%.%%w]*"):format(key)) do -- ROBLOX deviation: escape characters
					table.insert(ref, match)
				end
				return ref
			end)()
		)
	end
end

function replaceKeyPathWithValue(template: Template): (title: string, match: string) -> string
	return function(title: string, match: string)
		local newMatch = match:gsub("%$", "", 1) -- ROBLOX deviation: escape string
		local keyPath = String.split(newMatch, "%.") -- ROBLOX deviation: escape string
		local value = getPath(template, keyPath)
		if isPrimitive(value) then
			return title:gsub(match, tostring(value), 1)
		end
		return title:gsub(match, pretty(value, { maxDepth = 1, min = true }), 1)
	end
end
--[[ 1 ]]	{"Delete","Music ID","Radio","Game Info","Settings"},
--[[ 2 ]]	{"Yes","No"},
--[[ 3 ]]	{"Set","Play","Stop","Back"},
--[[ 4 ]]	{"Preset 1","Preset 2","Preset 3","Preset 4","Back"},
--[[ 5 ]]	{"Filtered","PGS","Players","Back"},
--[[ 6 ]]	{"Power","Dynamics","Background","Back"},
--[[ 7 ]]	{"Valet","Eco","Comfort","Sport","Back"},
--[[ 8 ]]	{"Eco","Comfort","Sport","Back"},
--[[ 9 ]]

 {"Model","Specs","Transmission","Info","Back"},
}

return module
-- Variables


local hasExploded = false

local function Explode()
	
	-- Don't allow this to execute multiple times
	if hasExploded then return end
	hasExploded = true
	
	wait(0.2)
	
	local Explosion = Instance.new("Explosion")
	Explosion.BlastRadius = 14
	Explosion.BlastPressure = 2000
	Explosion.DestroyJointRadiusPercent = 0

	Explosion.Position = RootModel:GetPrimaryPartCFrame().Position

	local parts = workspace:GetPartBoundsInRadius(Explosion.Position,Explosion.BlastRadius)

	-- So we don't rehit the same target multiple times
	local flaggedForHit = {}
	
	-- If the part is connected to a player character then apply damage
	for _, part in pairs(parts) do
		local character = PartUtility.GetCharacterFromInstance_R(part)
		if not character then continue end
		-- Don't rehit the same character multiple times
		if flaggedForHit[character] then continue end
		flaggedForHit[character] = true

		APICombat.ApplyDamageToCharacter(owningPlayer,character,WeaponDefinition)	
	end

	Explosion.Parent = workspace

	local effectPart = Instance.new("Part")
	effectPart.Position = Explosion.Position
	effectPart.Anchored = true
	effectPart.Transparency = 1
	effectPart.CanCollide = false
	effectPart.Parent = workspace

	-- Play sounds
	for _, effect in pairs(EffectsToPlay:GetChildren()) do
		effect.Parent = effectPart
		if effect:IsA("Sound") then
			effect:Play()
		end
	end

	DebrisService:AddItem(effectPart,4)

	RootModel:Destroy()
end

for _, part in pairs(RootModel:GetChildren()) do
	part.Touched:Connect(function(part)		
		local character = PartUtility.GetCharacterFromInstance_R(part)
		if owningPlayer.Character and owningPlayer.Character ~= character then
			Explode()
		end
	end)
end
--Char.Humanoid.BreakJointsOnDeath = false



if Config.EnableRagdoll == true then
	Char.Humanoid.Died:Connect(function()
		Ragdoll(Char)
	end)
end

human.HealthChanged:Connect(function (newhealth)

	if not dead.Value and Blood.Value >= 10 then
		if not Config.ZeroHealthEqualsDeath then
			human.Health = math.clamp(newhealth, 0.1, 100)
		else
			human.Health = math.clamp(newhealth, 0, 100)
		end



		if (rodeath.Value == true or life.Value == false) and newhealth <= -25 then
			local loss = newhealth * 40
			Blood.Value = Blood.Value + loss
			human.PlatformStand = true
			human.AutoRotate = false	
			Caido.Value = true

		end

	else
		human.PlatformStand = false
		human.AutoRotate = true
		human.Health = 0

	end
end)
--ControlSwitch



ControlSwch.Changed:Connect(function()
	if ControlSwch.Value == true then
		ControlSwch.Parent.P1.Transparency = 1
		ControlSwch.Parent.P2.Transparency = 0
		ControlVal.Value = true
		ClickSound:Play()
	else
		ControlSwch.Parent.P1.Transparency = 0
		ControlSwch.Parent.P2.Transparency = 1
		ClickSound:Play()
		ControlVal.Value = false
	end
end)
--[=[
	Performs a raycast operation out from the mouse position (or the
	`overridePos` if provided) into world space. The ray will go
	`distance` studs forward (or 1000 studs if not provided).

	Returns the `RaycastResult` if something was hit, else returns `nil`.

	Use `Raycast` if it is important to capture any objects that could be
	hit along the projected ray. If objects can be ignored and only the
	final position of the ray is needed, use `Project` instead.

	```lua
	local params = RaycastParams.new()
	local result = mouse:Raycast(params)
	if result then
		print(result.Instance)
	else
		print("Mouse raycast did not hit anything")
	end
	```
]=]


function Mouse:Raycast(raycastParams: RaycastParams, distance: number?, overridePos: Vector2?): RaycastResult?
	local viewportMouseRay = self:GetRay(overridePos)
	local result = workspace:Raycast(viewportMouseRay.Origin, viewportMouseRay.Direction * (distance or RAY_DISTANCE), raycastParams)
	return result
end
-- Hook events


Entry.TextBox.FocusLost:Connect(
	function(submit)
		return Window:LoseFocus(submit)
	end
)

UserInputService.InputBegan:Connect(
	function(input, gameProcessed)
		return Window:BeginInput(input, gameProcessed)
	end
)

Entry.TextBox:GetPropertyChangedSignal("Text"):Connect(
	function()
		if Entry.TextBox.Text:match("\t") then -- Eat \t
			Entry.TextBox.Text = Entry.TextBox.Text:gsub("\t", "")
			return
		end
		if Window.OnTextChanged then
			return Window.OnTextChanged(Entry.TextBox.Text)
		end
	end
)

Gui.ChildAdded:Connect(Window.UpdateWindowHeight)

return Window
--------------------------------------------------------------------------------
-- MAGIC NUMBERS CALCULATOR
--------------------------------------------------------------------------------
-- Q:
--    Is 53-bit "double" math enough to calculate square roots and cube roots of primes with 64 correct bits after decimal point?
-- A:
--    Yes, 53-bit "double" arithmetic is enough.
--    We could obtain first 40 bits by direct calculation of p^(1/3) and next 40 bits by one step of Newton's method.


do
	local function mul(src1, src2, factor, result_length)
		-- src1, src2 - long integers (arrays of digits in base TWO_POW_24)
		-- factor - small integer
		-- returns long integer result (src1 * src2 * factor) and its floating point approximation
		local result, carry, value, weight = table.create(result_length), 0, 0, 1
		for j = 1, result_length do
			for k = math.max(1, j + 1 - #src2), math.min(j, #src1) do
				carry = carry + factor * src1[k] * src2[j + 1 - k] -- "int32" is not enough for multiplication result, that's why "factor" must be of type "double"
			end

			local digit = carry % TWO_POW_24
			result[j] = math.floor(digit)
			carry = (carry - digit) / TWO_POW_24
			value = value + digit * weight
			weight = weight * TWO_POW_24
		end

		return result, value
	end

	local idx, step, p, one, sqrt_hi, sqrt_lo = 0, {4, 1, 2, -2, 2}, 4, {1}, sha2_H_hi, sha2_H_lo
	repeat
		p = p + step[p % 6]
		local d = 1
		repeat
			d = d + step[d % 6]
			if d * d > p then
				-- next prime number is found
				local root = p ^ (1 / 3)
				local R = root * TWO_POW_40
				R = mul(table.create(1, math.floor(R)), one, 1, 2)
				local _, delta = mul(R, mul(R, R, 1, 4), -1, 4)
				local hi = R[2] % 65536 * 65536 + math.floor(R[1] / 256)
				local lo = R[1] % 256 * 16777216 + math.floor(delta * (TWO_POW_NEG_56 / 3) * root / p)

				if idx < 16 then
					root = math.sqrt(p)
					R = root * TWO_POW_40
					R = mul(table.create(1, math.floor(R)), one, 1, 2)
					_, delta = mul(R, R, -1, 2)
					local hi = R[2] % 65536 * 65536 + math.floor(R[1] / 256)
					local lo = R[1] % 256 * 16777216 + math.floor(delta * TWO_POW_NEG_17 / root)
					local idx = idx % 8 + 1
					sha2_H_ext256[224][idx] = lo
					sqrt_hi[idx], sqrt_lo[idx] = hi, lo + hi * hi_factor
					if idx > 7 then
						sqrt_hi, sqrt_lo = sha2_H_ext512_hi[384], sha2_H_ext512_lo[384]
					end
				end

				idx = idx + 1
				sha2_K_hi[idx], sha2_K_lo[idx] = hi, lo % K_lo_modulo + hi * hi_factor
				break
			end
		until p % d == 0
	until idx > 79
end
--[[
	Takes two tables A and B, returns if they have the same key-value pairs
	Except ignored keys
]]


return function(A, B, ignore)
	if not A or not B then
		return false
	elseif A == B then
		return true
	end
	if not ignore then
		ignore = {}
	end

	for key, value in pairs(A) do
		if B[key] ~= value and not ignore[key] then
			return false
		end
	end
	for key, value in pairs(B) do
		if A[key] ~= value and not ignore[key] then
			return false
		end
	end

	return true
end
--!strict
--[=[
	@function at
	@within Array

	@param array {T} -- The array to get the value from.
	@param index number -- The index to get the value from (can be negative).
	@return T -- The value at the given index.

	Gets a value from an array at the given index.

	```lua
	local array = { 1, 2, 3 }

	local value = At(array, 1) -- 1
	local value = At(array, 0) -- 3
	```
]=]


local function at<T>(array: { T }, index: number): T
	local length = #array

	if index < 1 then
		index += length
	end

	return array[index]
end

return at
-- Allows the character to climb ladders and trusses like a rocket while
-- continuously jumping and walking into them. Overrides default jumping
-- velocity.
-- 
-- Thank you for your forum post Crazyblox! Saved me a lot of time figuring
-- the solution out.
-- 
-- https://devforum.roblox.com/t/humanoid-jump-state-not-triggering-from-truss-jump-with-shiftlock-first-person/242877
--
-- ForbiddenJ



Humanoid = script.Parent.Humanoid
RootPart = Humanoid.RootPart

Humanoid.Jumping:Connect(function(isJumping)
    if isJumping then
	    RootPart.Velocity = Vector3.new(RootPart.Velocity.X, Humanoid.JumpPower * 1.1, RootPart.Velocity.Z)
    end
end)
---------------------------------------------------



This = script.Parent
Elevator = This.Parent.Parent.Parent.Parent.Parent
CustomLabel = require(This.Parent.Parent.Parent.Parent.Parent.CustomLabel)
Characters = require(script.Characters)

CustomText = CustomLabel["CUSTOMFLOORLABEL"]

Elevator:WaitForChild("Floor").Changed:connect(function(floor)
	ChangeFloor(tostring(floor))
end)


function ChangeFloor(SF)
	if CustomText[tonumber(SF)] then
		SF = CustomText[tonumber(SF)]
	end
	SetDisplay(2,(string.len(SF) == 2 and SF:sub(1,1) or "NIL"))        
	SetDisplay(3,(string.len(SF) == 2 and SF:sub(2,2) or SF))
end



function SetDisplay(ID,CHAR)
	if This.Display:FindFirstChild("Matrix"..ID) and Characters[CHAR] ~= nil then
		for i,l in pairs(Characters[CHAR]) do 
			for r=1,5 do    
				This.Display["Matrix"..ID]["Row"..i]["D"..r].Visible = (l:sub(r,r) == "1" and true or false)
			end
		end
	end
end

for M = 1, Displays do
	for R = 1, 7 do
		for D = 1, 5 do
			This.Display["Matrix"..M]["Row"..R]["D"..D].ImageColor3 = DisplayColor
		end
	end
end
--[[
    Initialises a new StateHolder from defined config table, which should be formatted as below:
    allowedTransitions = {
        [StateName] = {} -- Within the table should be all the states this state can transition into
    }
    callbacks = {
		global = {onLeave = function(stateHolder, from, to), onEnter = function(stateHolder, from, to)}
        [StateName] = {onLeave = function(stateHolder, from, to), onEnter = function(stateHolder, from, to)}
    }
    initial -- Optional initial state to automatically transition into
]]


function StateHolder:_init(config)
	self._allowedTransitions = config.allowedTransitions
	self._callbacks = config.callbacks

	if config.initial then
		spawn(
			function()
				self:transition(config.initial, true)
			end
		)
	end
end
--[=[
	Repeatedly calls a Promise-returning function up to `times` number of times, until the returned Promise resolves.

	If the amount of retries is exceeded, the function will return the latest rejected Promise.

	```lua
	local function canFail(a, b, c)
		return Promise.new(function(resolve, reject)
			-- do something that can fail

			local failed, thing = doSomethingThatCanFail(a, b, c)

			if failed then
				reject("it failed")
			else
				resolve(thing)
			end
		end)
	end

	local MAX_RETRIES = 10
	local value = Promise.retry(canFail, MAX_RETRIES, "foo", "bar", "baz") -- args to send to canFail
	```

	@since 3.0.0
	@param callback (...: P) -> Promise<T>
	@param times number
	@param ...? P
]=]


function Promise.retry(callback, times, ...)
	assert(type(callback) == "function", "Parameter #1 to Promise.retry must be a function")
	assert(type(times) == "number", "Parameter #2 to Promise.retry must be a number")

	local args, length = {...}, select("#", ...)

	return Promise.resolve(callback(...)):catch(function(...)
		if times > 0 then
			return Promise.retry(callback, times - 1, unpack(args, 1, length))
		else
			return Promise.reject(...)
		end
	end)
end
--[=[
	Shares this observables state/computation with all down-stream observables. This can be useful
	when a very expensive computation was done and needs to be shared.

	Generally not needed.

	@param observable Observable<T>
	@return Observable<T>
]=]


function Blend.Shared(observable)
	return observable:Pipe({
		Rx.cache();
	})
end

function Blend.Dynamic(...)
	return Blend.Computed(...)
		:Pipe({
			-- This switch map is relatively expensive, so we don't do this for defaul computed
			-- and instead force the user to switch to another promise
			Rx.switchMap(function(promise, ...)
				if Promise.isPromise(promise) then
					return Rx.fromPromise(promise)
				elseif Observable.isObservable(promise) then
					return promise
				else
					return Rx.of(promise, ...)
				end
			end)
		})
end
--[[
	Handles client-side squash animations for the rooster NPCs around the market

	Note: Typically, using an actual AnimationTrack would be preferred because it gives more flexibility
	and is more performant than tweening properties. However, here we do the latter because this is a sample
	project, and use of animations is restricted to only the uploader. Therefore, if we used the Roblox animation system,
	the animations would not be available to anyone getting a standalone copy of this place.
--]]



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

local getInstance = require(ReplicatedStorage.Source.Utility.getInstance)

local SQUASH_FACTOR = 1.1
local ANIMATION_TIME = 0.6
local SQUASH_SCALAR = Vector3.new(SQUASH_FACTOR, 1 / SQUASH_FACTOR, SQUASH_FACTOR)

local random = Random.new()

local AnimatedRoosterNPC = {}
AnimatedRoosterNPC.__index = AnimatedRoosterNPC

export type ClassType = typeof(setmetatable(
	{} :: {
		_instance: Model,
		_loopedAnimationTween: Tween?,
	},
	AnimatedRoosterNPC
))

function AnimatedRoosterNPC.new(npcModel: Model): ClassType
	local self = {
		_instance = npcModel,
	}

	setmetatable(self, AnimatedRoosterNPC)

	-- Offset animations to add some variation across roosters
	task.delay(math.random() * ANIMATION_TIME, self._startAnimation, self)

	return self
end

function AnimatedRoosterNPC._startAnimation(self: ClassType)
	local mesh: MeshPart = getInstance(self._instance, "Mesh")
	local tweenInfo = TweenInfo.new(
		ANIMATION_TIME,
		Enum.EasingStyle.Back,
		Enum.EasingDirection.InOut,
		-1,
		true,
		random:NextNumber(1.5, 3)
	)
	local squashedMeshSize = mesh.Size * SQUASH_SCALAR

	local tween = TweenService:Create(mesh, tweenInfo, {
		Size = squashedMeshSize,
		CFrame = mesh.CFrame * CFrame.new(0, -(mesh.Size - squashedMeshSize).Y / 2, 0),
	})
	tween:Play()
	self._loopedAnimationTween = tween
end

function AnimatedRoosterNPC.destroy(self: ClassType)
	if self._loopedAnimationTween then
		self._loopedAnimationTween:Cancel()
	end
end

return AnimatedRoosterNPC
--- Same as indexing, but uses an incremented number as a key.
-- @param task An item to clean
-- @treturn number taskId


function Maid:GiveTask(task)
	assert(task)
	local taskId = #self._tasks+1
	self[taskId] = task
	return taskId
end

function Maid:GivePromise(promise)
	if not promise:IsPending() then
		return promise
	end

	local newPromise = promise.resolved(promise)
	local id = self:GiveTask(newPromise)

	-- Ensure GC
	newPromise:Finally(function()
		self[id] = nil
	end)

	return newPromise
end
--[[
	Provides an array of all item IDs in a specified parent, sorted by
	lowest purchase cost first, and alphabetical DisplayName second.

	This is used for items in the game meant to be displayed in a UI,
	such as pots and plants.
--]]



local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Sift = require(ReplicatedStorage.Dependencies.Sift)
local Attribute = require(ReplicatedStorage.Source.SharedConstants.Attribute)
local ContainerByCategory = require(ReplicatedStorage.Source.SharedConstants.ContainerByCategory)
local ItemCategory = require(ReplicatedStorage.Source.SharedConstants.ItemCategory)

local getAttribute = require(ReplicatedStorage.Source.Utility.getAttribute)

local function getSortedIdsInCategory(itemCategory: ItemCategory.EnumType)
	local models = ContainerByCategory[itemCategory]:GetChildren()
	local sortedModels: { Instance } = Sift.Array.sort(models, function(itemA: Instance, itemB: Instance)
		-- Coin bundles don't have Display Names or Purchase Costs
		if itemCategory == ItemCategory.CoinBundles then
			local itemAValue: number = getAttribute(itemA, Attribute.CoinBundleSize)
			local itemBValue: number = getAttribute(itemB, Attribute.CoinBundleSize)

			return itemAValue < itemBValue
		else
			local itemAName: number = getAttribute(itemA, Attribute.DisplayName)
			local itemBName: number = getAttribute(itemB, Attribute.DisplayName)

			local itemAValue: number = getAttribute(itemA, Attribute.PurchaseCost)
			local itemBValue: number = getAttribute(itemB, Attribute.PurchaseCost)

			-- Sort by cost first, alphabetical display name second
			if itemAValue == itemBValue then
				return itemAName < itemBName
			else
				return itemAValue < itemBValue
			end
		end
	end)

	-- Convert the array of models to an array of item IDs
	local sortedItemIds: { string } = Sift.Array.map(sortedModels, function(itemModel: Instance)
		return itemModel.Name
	end)

	return sortedItemIds
end

return getSortedIdsInCategory
--[[

= Sonic Onset Adventure Client =

Source: ControlScript/Player/Input/TouchButton.lua
Purpose: Mobile Touch Button class
Author(s): Regan "CD/TheGreenDeveloper" Green
 (badia modded 🤑)
--]]



local touch_button = {}

local gui_service = game:GetService("GuiService")
local uis = game:GetService("UserInputService")
--http://robloxdev.com/code-sample/Weld-Code-Sample-1


local function Weld(part0, part1, parent)
	local weld = Instance.new("WeldConstraint")
	weld.Part0 = part0
	weld.Part1 = part1
	weld.Parent = parent or part0
	
	return weld
end

local function WeldParts(parts, main, unanchor)
	for i,v in pairs(parts) do
		Weld(main, v)
	end
	
	if not unanchor then
		for i = 1, #parts do
			parts[i].Anchored = false
		end
		main.Anchored = false
	end
end
-- Function to check whether the player can send an invite


local function canSendGameInvite(sendingPlayer)
	local success, canSend = pcall(function()
		return SocialService:CanSendGameInviteAsync(sendingPlayer)
	end)
	return success and canSend
end

button.Activated:Connect(function()
	local canInvite = canSendGameInvite(player)
	if canInvite then
		local success, errorMessage = pcall(function()
			SocialService:PromptGameInvite(player)
		end)
	end
end)