I am working on a script for a map of a game that I will be making. It is kind of like the chaser system in s4 league.
My problem is that once everybody has their "waschaser" set to true, the script should issue a "close map" notice, but once everybody has been chaser, nothing happens and I cant figure out why.
Here is how my table is set up
chaserdb_players = { }
chaserdb_players[charname] = { score = 0, death = 0, kill = 0, waschaser = false }
Now once the map has started, it will search for the next available person with waschaser = false.
for characterName,i in next, chaserdb_players do
if (i.waschaser == false) then
local player = getPlayerByName(characterName, map_copy)
if (player ~= nil) then
addChaserState(player)
break
end
end
end
in the addChaserState(player) function it switches the waschaser = true for that character.
What I am having issues with is that once everybody in the map has their waschaser = true, I need a system notice to start, which i have attempted by doing
for characterName,i in next, chaserdb_players do
if (i.waschaser == false) then
local player = getPlayerByName(characterName, map_copy)
if (player ~= nil) then
addChaserState(player)
break
end
else
Notice("All players have been chaser! The map will close in 30 seconds!")
map_close = true
end
end
here is the getPlayerByName function
function getPlayerByName(name, map_copy)
BeginGetMapCopyPlayerCha(map_copy)
for i = 0 , chaserdb_playercount - 1 , 1 do
local player = GetMapCopyNextPlayerCha ( map_copy )
if (player == 0 or player == nil) then
return nil
else
local playerName = GetChaDefaultName(player)
if (playerName == name) then
return player
end
end
end
end
But that does not work.
Can anybody help? If you need more information feel free to let me know and I will add it.
Move your notice outside the for loop. And use a boolean flag to check for any possible errors:
local bFlag = true
for i,characterName in next, chaserdb_players do
if (characterName.waschaser == false) then
local player = getPlayerByName(i, map_copy)
if (player ~= nil) then
addChaserState(player)
break
end
else
bFlag = false
end
end
if bFlag then
Notice("All players have been chaser! The map will close in 30 seconds!")
map_close = true
end
Slightly more idiomatically:
local allChased = true
for name, character in pairs(chaserdb_players) do
if not character.waschaser then
local player = getPlayerByName(name, map_copy)
if player then
addChaserState(player)
break
end
else
allChased = false
end
end
if allChased then
Notice("All players have been chaser! The map will close in 30 seconds!")
map_close = true
end
Wrapping that in a function works well:
function nextChaser()
for name, character in ipairs(chaserdb_players) do
if not character.waschaser then
local player = getPlayerByName(name, map_copy)
if player then
return player
end
end
end
end
local player = nextChaser()
if player then
addChaserState(player)
else
Notice("All players have been chaser! The map will close in 30 seconds!")
map_close = true
end
Related
local me = script.Parent
local players = game:GetService("Players")
me.Touched:Connect(function(Hit)
local player = players:GetPlayerFromCharacter(Hit.Parent)
if player.TookMoney.Value == true then
player.TookMoney.Value = false
end
end)
It has to make TookMoney.Value = false but it says "attempt to index nil with 'TookMoney' -script:6"
The touched event is triggered on all objects, including non players. Thus players:GetPlayerFromCharacter can return nil. Perform a nil check, e.g.:
me.Touched:Connect(function(Hit)
local player = players:GetPlayerFromCharacter(Hit.Parent)
if player and player.TookMoney.Value == true then
player.TookMoney.Value = false
end
end)
Depending on your setup you may also check if the player has TookMoney.
I'm first going to start off with my code which is in a Server Script:
local an = Instance.new("Animation")
an.AnimationId = "rbxassetid://11699868187"
local idle = Instance.new("Animation")
idle.AnimationId = "rbxassetid://11699874417"
local ant
local idlet
local canthit = {}
local knockTime = 30
function takeOwnership(model)
for i, v in pairs(model:GetDescendants()) do
if v:IsA("Part") or v:IsA("BasePart") then
repeat
v:SetNetworkOwner(nil)
until v:GetNetworkOwner() == nil
end
end
end
function resetOwernship(model, ply)
for i, v in pairs(model:GetDescendants()) do
if v:IsA("Part") or v:IsA("BasePart") then
v:SetNetworkOwner(ply)
end
end
end
function rag(char)
local ah = Instance.new("IntValue")
ah.Parent = char
ah.Name = "MaxTime"
ah.Value = knockTime
local thib = Instance.new("IntValue")
thib.Parent = char
thib.Name = "Time"
thib.Value = knockTime
for i, v in pairs(char:GetDescendants()) do
if v:IsA("Motor6D") and v.Parent.Name ~= "HumanoidRootPart" then
local Socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Parent = v.Part0
a2.Parent = v.Part1
Socket.Parent = v.Parent
Socket.Attachment0 = a1
Socket.Attachment1 = a2
a1.CFrame = v.C0
a2.CFrame = v.C1
Socket.LimitsEnabled = true
Socket.TwistLimitsEnabled = true
v:Destroy()
end
end
char.Humanoid.BreakJointsOnDeath = false
char.Humanoid.RequiresNeck = false
end
function unrag(char)
for i,v in pairs(char:GetDescendants()) do
if v:IsA("BallSocketConstraint") then
v.UpperAngle = 0
v.TwistUpperAngle = 0
v.TwistLowerAngle = 0
local Joints = Instance.new("Motor6D",v.Parent)
Joints.Part0 = v.Attachment0.Parent
Joints.Part1 = v.Attachment1.Parent
Joints.C0 = v.Attachment0.CFrame
Joints.C1 = v.Attachment1.CFrame
v:Destroy()
end
end
end
game:GetService("ReplicatedStorage").Jump.OnServerEvent:Connect(function(ply)
if ply.Character and ply.Team == game:GetService("Teams").Survivor then
if ply.Character.Ragdoll.Value == true then
--game:GetService("ReplicatedStorage"):WaitForChild("Message"):FireClient(ply, "Sorry, jumping isn't available for ragdolls right now")
end
end
end)
game.Players.PlayerAdded:Connect(function(p)
if #game:GetService("Teams").Beast:GetPlayers() == 1 then
p.Team = game:GetService("Teams").Survivor
else
p.Team = game:GetService("Teams").Beast
end
p.CharacterAdded:Connect(function(c)
canthit[p] = nil
if p.Team == game:GetService("Teams").Beast then
local theBat = game:GetService("ServerStorage").Bat:Clone()
theBat.Parent = c
theBat.Equipped:Connect(function()
local h = c:FindFirstChild("Humanoid")
if h then
local a = h:FindFirstChild("Animator")
if a then
idlet = a:LoadAnimation(idle)
idlet:Play()
end
end
end)
theBat.Activated:Connect(function()
local h = c:FindFirstChild("Humanoid")
if h then
local a = h:FindFirstChild("Animator")
if a then
ant = a:LoadAnimation(an)
ant:Play()
theBat.Handle.Swoosh:Play()
local thinge = theBat.Handle.Touched:Connect(function(t)
local ply = game.Players:GetPlayerFromCharacter(t:FindFirstAncestorWhichIsA("Model"))
local ragd = ply.Character:FindFirstChild("Ragdoll")
if ragd then
if ragd.Value == true then
return
end
end
if ply and ply.Team == game:GetService("Teams").Survivor and ply ~= p and not canthit[ply] then
theBat.Handle.Hit:Play()
canthit[ply] = true
local char = ply.Character
ragd.Value = true
rag(char)
while not (char.Time.Value <= 0) do
takeOwnership(char)
char.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
wait(1)
char.Time.Value -= 1
char.HP.Value -= .5
end
if char.HP.Value <= 0 then
char.HP.Value = 0
game:GetService("ReplicatedStorage"):WaitForChild("Message"):FireAllClients(ply.Name.." has been captured!")
char.Humanoid.Health = 0
return
end
char.Time:Destroy()
char.MaxTime:Destroy()
char.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
unrag(char)
resetOwernship(char, ply)
ragd.Value = false
coroutine.wrap(function()
wait(5)
canthit[ply] = nil
end)()
end
end)
wait(.2)
thinge:Disconnect()
end
end
end)
theBat.Unequipped:Connect(function()
if idlet then
idlet:Stop()
end
end)
end
end)
end)
So, this is my horrible code for a little game I am making. It's kind of similar to Flee the Facility. In my game, the person who is the 'beast' should be able to drag a player when they are knocked out, but they can't. I tried adding a rope constraint to the ragdoll and the 'beast', but it just makes the beast have input lag and makes it's animations go weird.
I must note that the beast is a random player. I would try setting ownership of the ragdoll'd player to the grabber (which is the 'beast') but I need to set it to the server in order to change the state to Physics. I would use an event and a local script but I do not want this to be exploitable at all.
So, my question is: How do I attach a rope from a player to a ragdolled player without the non-ragdolled player lagging or having weird input lag and weird animations?
Like I said, I tried setting ownership but that wouldn't work as I need server ownership for setting the humanoid's state to physics. Just using takeOwnership() then ChangeState both on the same line wouldn't work so I had to put it in the while loop.
So, Im tring to make a Mind Control script inside of Roblox. Im using the local script so i can use the UserInputServer Module. But When I Run It(Its inside of StartGui), I doesn't give any output. Here is the source:
--Made By BioShot!--
local UIS = game:GetService("UserInputService")
local Enabled = false
local Active = false
game.Players.PlayerAdded:Connect(function(plr)
print("Player Added!")
UIS.InputBegan:Connect(function(input)
if(input['KeyCode'] == Enum['KeyCode']["E"]) then
if(Enabled == true) then
--Rase Player/Dummy/NPC
local Mouse = plr:GetMouse()
Active = true
while(Active == true) do
local Enemy = Mouse["Target"]
print(Enemy)
Enemy.CFrame = Enemy.CFrame + CFrame.new(0,1,0)
wait(0.5)
end
else
--Drop Player/Dummy/NPC
end
end
end)
UIS.InputEnded:Connect(function(input)
if(input['KeyCode'] == Enum["KeyCode"]["F"]) then
Enabled = true
print("Enabled.")
end
if(input['KeyCode'] == Enum["KeyCode"]["E"]) then
Active = false
end
end)
end)
The statements are only printed after game.Players.PlayerAdded:Connect(function(plr) detects a player being added. Due to the code running in a LocalScript, the player will have already been added by the time the script starts waiting for players. If a second player joins the game, "Player Added!" will indeed be printed in the first player's console.
The player can instead be indexed by using local plr = game:GetService("Players").LocalPlayer.
The script still errors when the player's mouse is pointing to nothing and when trying to change the Enemy's position, but these can be easily fixed. The script then lifts objects upwards by hovering over them and pressing E.
Final code:
--Made By BioShot!--
local UIS = game:GetService("UserInputService")
local Enabled = false
local Active = false
local plr = game:GetService("Players").LocalPlayer
print("Player Added!")
UIS.InputBegan:Connect(function(input)
if(input['KeyCode'] == Enum['KeyCode']["E"]) then
if(Enabled == true) then
--Rase Player/Dummy/NPC
local Mouse = plr:GetMouse()
Active = true
while(Active == true) do
local Enemy = Mouse["Target"]
if Enemy then --Make sure the player's mouse isn't pointing to nothing
print(Enemy)
Enemy.CFrame += Vector3.new(0,1,0)
end
task.wait(0.5) --More accurate than wait(0.5)
end
else
--Drop Player/Dummy/NPC
end
end
end)
UIS.InputEnded:Connect(function(input)
if(input['KeyCode'] == Enum["KeyCode"]["F"]) then
Enabled = true
print("Enabled.")
end
if(input['KeyCode'] == Enum["KeyCode"]["E"]) then
Active = false
end
end)
For a bit of context, I'm making a Tycoon on Roblox to test my knowledge in lua. Everything was working fine until I tried making leaderstats. The first script, which is what makes the Tycoon
function, is here:
local TycoonInfo = script.Parent:WaitForChild("TycoonInfo")
local OwnerValue = TycoonInfo:WaitForChild("Owner")
local Buttons = script.Parent:WaitForChild("Buttons")
local Purchases = script.Parent:WaitForChild("Purchases")
local Objects = {}
function validateHitByOwner(Hit)
if Hit and Hit.Parent and Hit.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Player and OwnerValue.Value== Player then
return true
end
end
return false
end
for i,v in pairs(Buttons:GetChildren()) do
local Object = Purchases:FindFirstChild(v.Object.Value)
if Object then
Objects[Object.Name] = Object:Clone()
Object:Destroy()
if v:FindFirstChild("Dependency") then
coroutine.resume(coroutine.create(function()
v.Button.Transparency = 1
v.Button.BillboardGui.Enabled = false
v.Button.CanCollide = false
if Purchases:WaitForChild(v.Dependency.Value,90000) then
v.Button.Transparency = 0
v.Button.CanCollide = true
v.Button.BillboardGui.Enabled = true
end
end))
end
local DB = false
v.Button.Touched:Connect(function(Hit)
if validateHitByOwner(Hit)then
if DB == false then
DB = true
if v.Button.Transparency == 0 then
local Purchased = DoPurchase(Hit,v,v.Price.Value,Objects[v.Object.Value])
if Purchased then
warn("Purchased")
else
warn("Can't purchase")
end
end
DB = false
end
end
end)
end
end
function DoPurchase(Hit,Button,Cost,Object)
if Hit and Hit.Parent and Hit.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Player and OwnerValue.Value == Player then
local name = game.Players:GetChildren()
local CashValue = game.Players.name.leaderstats.Cash -- Error here
if CashValue then
if CashValue.Value >= Cost then
CashValue.Value = CashValue.Value - Cost
Object.Parent = Purchases
Button:Destroy()
return true
end
end
end
end
return false
end
The next script, which makes the leaderboard and assigns a player that has recently joined to a random available Tycoon, is here:
function FindEmptyTycoon()
for i,v in pairs(workspace.Tycoons:GetChildren()) do
if v.TycoonInfo.Owner.Value == nil then
return v
end
end
return nil
end
game.Players.PlayerAdded:Connect(function(Player)
local Tycoon = FindEmptyTycoon()
Tycoon.TycoonInfo.Owner.Value = Player
local stats = Instance.new("Folder",Player)
stats.Name = "leaderstats"
local Cash = Instance.new("IntValue",stats)
Cash.Name = "Cash"
end)
And then, the script that is stored in all purchasable items to give the Player money, is here:
function giveCash(player)
wait(3.33)
local Cash = player.leaderstats.Cash
Cash.Value = Cash.Value + 2
end
By the way, these scripts are versions of the original scripts that I've been trying to edit so they can actually work, and I think I've been getting close to fixing the errors. The original scripts can be found here (in order of appearance):
local TycoonInfo = script.Parent:WaitForChild("TycoonInfo")
local OwnerValue = TycoonInfo:WaitForChild("Owner")
local Buttons = script.Parent:WaitForChild("Buttons")
local Purchases = script.Parent:WaitForChild("Purchases")
local Objects = {}
function validateHitByOwner(Hit)
if Hit and Hit.Parent and Hit.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Player and OwnerValue.Value== Player then
return true
end
end
return false
end
for i,v in pairs(Buttons:GetChildren()) do
local Object = Purchases:FindFirstChild(v.Object.Value)
if Object then
Objects[Object.Name] = Object:Clone()
Object:Destroy()
if v:FindFirstChild("Dependency") then
coroutine.resume(coroutine.create(function()
v.Button.Transparency = 1
v.Button.BillboardGui.Enabled = false
v.Button.CanCollide = false
if Purchases:WaitForChild(v.Dependency.Value,90000) then
v.Button.Transparency = 0
v.Button.CanCollide = true
v.Button.BillboardGui.Enabled = true
end
end))
end
local DB = false
v.Button.Touched:Connect(function(Hit)
if validateHitByOwner(Hit)then
if DB == false then
DB = true
if v.Button.Transparency == 0 then
local Purchased = DoPurchase(Hit,v,v.Price.Value,Objects[v.Object.Value])
if Purchased then
warn("Purchased")
else
warn("Can't purchase")
end
end
DB = false
end
end
end)
end
end
function DoPurchase(Hit,Button,Cost,Object)
if Hit and Hit.Parent and Hit.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Player and OwnerValue.Value == Player then
local CashValue = game.ServerStorage.PlayerCash:FindFirstChild(Player.Name)
if CashValue then
if CashValue.Value >= Cost then
CashValue.Value = CashValue.Value - Cost
Object.Parent = Purchases
Button:Destroy()
return true
end
end
end
end
return false
end
function FindEmptyTycoon()
for i,v in pairs(workspace.Tycoons:GetChildren()) do
if v.TycoonInfo.Owner.Value == nil then
return v
end
end
return nil
end
game.Players.PlayerAdded:Connect(function(Player)
local Tycoon = FindEmptyTycoon()
Tycoon.TycoonInfo.Owner.Value = Player
local stats = Instance.new("BoolValue",Player)
stats.Name = "leaderstats"
stats.Parent = game.ServerStorage
local Cash = Instance.new("IntValue",stats)
Cash.Name = Player.Name
Cash.Value = 0
Cash.Parent = game.ServerStorage.PlayerCash
end)
local amount = 2
local timedelay = 2.33
local currencyname = "Cash"
wait(1)
while true do
wait(timedelay)
for i,v in pairs(game.ServerStorage.PlayerCash:GetChildren()) do
if v:FindFirstChild("leaderstats") and v then
v.leaderstats[currencyname].Value = v.leaderstats[currencyname].Value + amount
end
end
end
local name = game.Players:GetChildren()
Why do you store the list of Players's children in a variable called name? This function returns a table. name would be more suitable for a string.
local CashValue = game.Players.name.leaderstats.Cash -- Error here
game.Players is https://developer.roblox.com/en-us/api-reference/class/Players
I cannot make sense of game.Players.name and even less of game.Players.name.leaderstats
Did you mean Player.leaderstats?
I would expect an error message for Players.name.leaderstats before facing an error for game.Players.name.leaderstats.Cash
name is not a Property of Players so you should not be allowed to index Players.name
I'm no Roblox expert but from what I see your code is so off that you really should start with simple tutorials rather than with fixing this code.
I think you should start over and make sure you understand how Instance.new is used properly and such things.
Using better variable names will also help.
So I thought of having this for so long, I just don't know where to start. I am new to this language and I keep learning, but kind of hard for me. But I have built my very own custom character which took 2 weeks for me. Anyway, For my question. An example is if I have a button and I click it, a model will be clone and I can drag that model and put it anywhere nearby. What possible method I can use to achieve this?
First things first, I suggest for any future questions, you head over to https://scriptinghelpers.org/
now, on to your question, for cloning the model, you should use mouse.Target.Parent:Clone() or the GetTopParent(mouse.Target) function in my function library (which you can get here; http://www.roblox.com/item.aspx?id=244244638)
then deposit the model into workspace and MakeJoints()
the next step is to move the model, this can be tricky, but the simplest method is model:MoveTo(mouse.Hit.p) on mouse.Moved (but that's a little buggy)
Another method for movement would be to use the Handles class, but I'm not really familiar with it, so you'd have to figure that one out on your own.
To make the first method less buggy, I'd suggest something along the lines of
model:MoveTo(mouse.Hit.p.X, mouse.Target.Position.Y + (model:GetExtentsSize().Y / 2), mouse.Hit.p.Z)
but you'd have to set up the mouse to ignore the model, which I can't really help with.
A really good place to start is to search the free models in Studio Toolbox for a 'Dragger Tool' or 'Model Dragger Tool' and then use the script inside to get started creating your own. I have learned to create my own custom draggers by doing this and it is way easier than you may think at first. Once you find a good dragger tool to borrow code from, if you need to enhance it, you can find the dragger api in the Roblox Wiki to help you further customize it to your specific needs.
http://wiki.roblox.com/index.php?title=API:Class/Dragger
EDIT: So here's the first dragger script that showed when I searched. It will drag models and parts but you will have to edit it to meet your requirements using the dragger api. Create a Tool in player.BackPack then create a LocalScript inside the Tool then copy and paste the code below into the LocalScript, and that will get you started.
local Tool = script.Parent
enabled = true
local origTexture = Tool.TextureId
game:GetService("ContentProvider"):Preload("rbxasset://icons/freemove_sel.png")
local selectionBox
local currentSelection
local currentSelectionColors = {}
local selectionLasso
local inGui = false
local inPalette = false
local lockTime = 0
function canSelectObject(part)
return part and not (part.Locked) and (part.Position - script.Parent.Parent.Head.Position).Magnitude < 60
end
function findModel(part)
while part ~= nil do
if part.className == "Model" then
return part
end
part = part.Parent
end
return nil
end
function startDrag(mousePart, hitPoint, collection)
dragger = Instance.new("Dragger")
pcall(function() dragger:MouseDown(mousePart, hitPoint, collection) end)
end
function collectBaseParts(object, collection)
if object:IsA("BasePart") then
collection[#collection+1] = object
end
for index,child in pairs(object:GetChildren()) do
collectBaseParts(child, collection)
end
end
function onMouseDown(mouse)
mouse.Icon ="rbxasset://textures\\GrabRotateCursor.png"
local part = mouse.Target
if canSelectObject(part) then
local hitPoint = mouse.Hit:toObjectSpace(part.CFrame).p
if trySelection(part) then
local instances = {}
collectBaseParts(currentSelection, instances)
startDrag(part, hitPoint, instances)
return
end
end
--Clear the selection if we weren't able to lock succesfullu
onMouseUp(mouse)
end
function onMouseUp(mouse)
mouse.Icon ="rbxasset://textures\\GrabCursor.png"
if dragger ~= nil then
pcall(function() dragger:MouseUp() end)
dragger = nil
end
end
function trySelection(part)
if canSelectObject(part) then
selectionLasso.Part = part
local model = findModel(part)
if model then
return setSelection(model)
else
return setSelection(part)
end
else
clearSelection()
return false
end
end
function onKeyDown(key)
if dragger ~= nil then
if key == 'R' or key == 'r' then
dragger:AxisRotate(Enum.Axis.Y)
elseif key == 'T' or key == 't' then
dragger:AxisRotate(Enum.Axis.Z)
end
end
end
local alreadyMoving
function onMouseMove(mouse)
if alreadyMoving then
return
end
alreadyMoving = true
if dragger ~= nil then
--Maintain the lock
if time() - lockTime > 3 then
Instance.Lock(currentSelection)
lockTime = time()
end
--Then drag
pcall(function() dragger:MouseMove(mouse.UnitRay) end)
else
trySelection(mouse.Target)
end
alreadyMoving = false
end
function saveSelectionColor(instance)
if instance:IsA("BasePart") then
currentSelectionColors[instance] = instance.BrickColor
if instance.BrickColor == BrickColor.Blue() then
instance.BrickColor = BrickColor.new("Deep blue")
else
instance.BrickColor = BrickColor.Blue()
end
end
local children = instance:GetChildren()
if children then
for pos, child in pairs(children) do
saveSelectionColor(child)
end
end
end
function setSelection(partOrModel)
if partOrModel ~= currentSelection then
clearSelection()
if Instance.Lock(partOrModel) then
lockTime = time()
currentSelection = partOrModel
saveSelectionColor(currentSelection)
selectionBox.Adornee = currentSelection
return true
end
else
if currentSelection ~= nil then
if time() - lockTime > 2 then
--Maintain the lock
if not(Instance.Lock(currentSelection)) then
--we lost the lock
clearSelection()
return false
else
lockTime = time()
return true
end
else
return true
end
end
end
return false
end
function clearSelection()
if currentSelection ~= nil then
for part, color in pairs(currentSelectionColors) do
part.BrickColor = color
end
selectionBox.Adornee = nil
Instance.Unlock(currentSelection)
end
currentSelectionColors = {}
currentSelection = nil
selectionLasso.Part = nil
selectionBox.Adornee = nil
end
function onEquippedLocal(mouse)
Tool.TextureId = "rbxasset://icons/freemove_sel.png"
local character = script.Parent.Parent
local player = game.Players:GetPlayerFromCharacter(character)
inGui = false
inPalette = false
mouse.Icon ="rbxasset://textures\\GrabCursor.png"
mouse.Button1Down:connect(function() onMouseDown(mouse) end)
mouse.Button1Up:connect(function() onMouseUp(mouse) end)
mouse.Move:connect(function() onMouseMove(mouse) end)
mouse.KeyDown:connect(function(string) onKeyDown(string) end)
selectionBox = Instance.new("SelectionBox")
selectionBox.Name = "Model Delete Selection"
selectionBox.Color = BrickColor.Blue()
selectionBox.Adornee = nil
selectionBox.Parent = player.PlayerGui
selectionLasso = Instance.new("SelectionPartLasso")
selectionLasso.Name = "Model Drag Lasso"
selectionLasso.Humanoid = character.Humanoid
selectionLasso.archivable = false
selectionLasso.Visible = true
selectionLasso.Parent = game.workspace
selectionLasso.Color = BrickColor.Blue()
alreadyMoving = false
end
function onUnequippedLocal()
Tool.TextureId = origTexture
clearSelection()
selectionBox:Remove()
selectionLasso:Remove()
end
Tool.Equipped:connect(onEquippedLocal)
Tool.Unequipped:connect(onUnequippedLocal)