Skyman772Join Date: 2012-03-20 Post Count: 9305 |
This common debounce function!
function debounce(func)
local isRunning = false
return function(...)
if not isRunning then
isRunning = true
func(...)
isRunning = false
end
end
end |
|
SeranokJoin Date: 2009-12-12 Post Count: 11083 |
128GB: If the player's aren't on a team, then why the heck is your function about getting players on a team?
Skyman772: Okay, I will add debounce. |
|
|
Player team changing.
"I like to program." - Bosswalrus |
|
|
Woops didn't know you put that in.
"I like to program." - Bosswalrus |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
Because it gets players with that TeamColor
And if you set the second argument to not nil, it gets the neutral ones too
(If you leave it nil then it only gets ones that aren't neutral) |
|
|
Perhaps how to detect KeyHolding.
"I like to program." - Bosswalrus |
|
RefactorJoin Date: 2014-04-20 Post Count: 487 |
--[[
http://lua-users.org/wiki/SimpleRound
--]]
function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
|
|
|
|
I don't know what you should add.
"I like to program." - Bosswalrus |
|
|
|
Mouse.Target code snippets?
"I like to program." - Bosswalrus |
|
|
Teleporting players to different places?
"I like to program." - Bosswalrus |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
@Refact
local function round(x, y)
return (math.floor((x / (y or 1)) + 0.5) * (y or 1));
end
print(round(0.3)) -->0
print(round(0.5)) -->1
print(round(2.3, 4)) -->4
print(round(6.1, 4)) -->8 |
|
|
Giving a hat/gear/whatever to a Player's Character with that InsertService or AssetService thingy.
"I like to program." - Bosswalrus |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
function getHat(id)
if game:GetService("MarketplaceService"):GetProductInfo(tonumber(id)).AssetTypeId == 8 then
return game:GetService("InsertService"):LoadAsset(tonumber(id)):GetChildren()[1]
end
return nil
end |
|
|
SeranokJoin Date: 2009-12-12 Post Count: 11083 |
MilkTreatGolem: Okay fixed |
|
|
Disabling jump.
"I like to program." - Bosswalrus |
|
|
Giving a shirt and pants to a Character and removing their current ones.
People ask for that script all the time(Uniform script).
"I like to program." - Bosswalrus |
|
|
There is a way without doing the for loop and finding the hat in the model. |
|
SeranokJoin Date: 2009-12-12 Post Count: 11083 |
@AbstractMadness How? In some hats, the first instance is not a hat, it's a thumbnail camera or something else. |
|
|
A giver that gives the Character a tool, this is also asked a lot.
"I like to program." - Bosswalrus |
|
|
The thumbnail camera is inside the hat itself, if I'm correct.
There was another way to load the asset though, without it being a model. I forgot how though, sorry. |
|
|
function WhileKeyHeldDown(key, func)
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.KeyDown:connect(function(k)
if k == key:lower() then
local b = false
local Connection = mouse.KeyUp:connect(function(kk)
if kk == key:lower() then
b = true
end
end)
while not b do
game:GetService("RunService").RenderStepped:wait()
func()
end
Connection:disconnect()
end
end)
end
--Please test this first, usage:
WhileKeyHeldDown("k", function()
print("Hello")
end)
--Must only be called in a LocalScript |
|
|