Search
 
SCRIPT & CODE EXAMPLE
 

LUA

lua roblox function

function NameOfFuction()
	--Your code
end    
Comment

Roblox lua

//zero gravity ball script
script.Parent.Activated:Connect(function()
	local part = Instance.new("Part")
	local fire = Instance.new("Fire")
	local force = script.Parent.cloneme:Clone()
	force.Parent = part
	fire.Parent = part
	part.Shape = Enum.PartType.Ball
	part.Parent = game.Workspace
	part.Position = script.Parent.Handle.Position
	part.Touched:Connect(function(otherpart)
		local Brick = part
		local function PlayerTouched(Part)
			local Parent = Part.Parent
			if game.Players:GetPlayerFromCharacter(Parent) then
				Parent.Humanoid.WalkSpeed = 32
			end
		end

		Brick.Touched:connect(PlayerTouched)
	end)
end)


//zero gravity script rember to always name part Handle and put it in tool in 
starter pack with these two scripts
local part = script.Parent

local force = Instance.new("BodyForce")
force.Parent = part

local antigrav = workspace.Gravity * part:GetMass()

force.Force = Vector3.new(0, antigrav, 0)

Comment

lua roblox

--[[
The UserInputService allows the developer to do a certain thing once a Key
is pressed. 
UserInputService ONLY WORKS IN A CLIENT SCRIPT!!
--]]

local UIS = game:GetService("UserInputService") -- Get the Service

UIS.InputBegan:Connect(function(input, gameProcessedEvent)
--[[
The input is whatever key the player presses on their keyboard. 
The gameProcessedEvent is true if the player is chatting, sitting down or doing
core Roblox things. In most cases you want to only run your script if it is false.
--]]
	if not gameProcessedEvent and input.KeyCode == Enum.KeyCode.R then
    	print("The player pressed the "..input.KeyCode.Name.." Key!")
	end
end)

UIS.InputEnded:Connect(function(input, gpe)
	if not gpe and input.KeyCode == Enum.KeyCode.R then
    	print("The player stopped holding the "..input.KeyCode.Name.:" Key!")
	end
end)

-- [[
NOTE !!!!!!!!!! 
InputEnded MUST be used in a synchronized script.
--]]
Comment

Roblox lua

/why won't this work?
print("loop")
repeat
	
until
/well its actually
while true do
	wait(1)
	print("loop")
end
/or
local timeout = 10 
local Time = 0

while true do
	wait(1)
	print("looping")
	Time = Time + 1
	if Time == timeout then
		break
		
	end
end

Comment

Roblox Lua

---how Not to use humanoids correctly-----------------
script.Parent.Touched:Connect(function(otherpart)
	local Humanoid = otherpart:FindFirstChild("Humanoid")
    if Humanoid ~= nil then
    Humanoid.Health = 0
    end
end)
--so lets see whats wrong here
--first the otherpart is touching the hurt brick not the model 
--which means that its telling the part the touched the hurt brick
--to find the child within the foot yeah not going to work 
------------------how to do it correctly-----------------------------------------------------

script.Parent.Touched:Connect(function(otherpart)
	local Humanoid = otherpart.parent:FindFirstChild("Humanoid")
    if Humanoid ~= nil then
    Humanoid.Health = 0
    end
end)
so if you were to make the parent of the part model which has the humanoid in it 
it will find humanoid and hurt the model with the hurt brick
-----------------------how not to use a teleport brick correctly------------------------------------
script.Parent.Touched:Connect(function(otherpart)
local Humanoid = otherpart.parent:FindFirstChild("Humanoid")
if Humanoid ~= nil then
Humanoid.RootPart.Position = Vector3.new(1,35,6)
end
end)
--well  you're not suppposed to use Vector3.new for teleport brick
--but you still can if you really want too use that method anyways 
--here is the correct way to do it
----------------how to use a teleport brick correctly----------------------------------------
script.Parent.Touched:Connect(function(otherpart)
local Humanoid = otherpart.parent:FindFirstChild("Humanoid")
if Humanoid ~= nil then
Humanoid.RootPart.Position = game.workspace.TeleportBrick1.position---or two if you want it to teleport you back on the other brick
end
end)
--thats all i can give you for advice currently
Comment

Roblox lua

----------------moving model script will go on forever---------------------------------------
local model = script.Parent --make sure script.parent Is a model
while true do --loop two 
	model:TranslateBy(Vector3.new(0.05, 0, 0))---makes it move
	wait()
	
end
-------------------moving script will move until the timer is done---------------------------
local disablescript = script.Parent.keep -- ps this is a script just name the script something else so you dont get confused
local tim = 0 
local timer = 5 --any number works here

while wait(1) do 
	---every secound it will add to the timer until it stops i recomend to only edit it to 60 sec or it will get more complex
	tim = tim + 1
	if tim == timer then --dont want it to keep going here too
		disablescript.Disabled = true
		script.Disabled = true
	end
end
-------------------------------put both of these scripts in two separate scripts keep them inside the model you want to move though
local model = script.Parent --make sure both scripts are in a model
while true do --loop two 
	model:TranslateBy(Vector3.new(0.05, 0, 0))---makes it move
	wait()
end



Comment

PREVIOUS NEXT
Code Example
Lua :: roblox lua exploiting rconsole 
Matlab :: if directory exist matlab 
Matlab :: matlab title figure 
Matlab :: switch matlab 
Matlab :: matlab if 
Matlab :: octave mark axis labels 
Matlab :: matlab make symbolic matrix 
Matlab :: matlab symbolic integration 
Matlab :: alternative from two vectors matlab 
Matlab :: geom_density_2d 
Basic :: add user to multiple groups ubuntu 
Basic :: basic authentication in REST api Dajngo 
Basic :: dos assign command output to variable (when output is of multiple lines) 
Elixir :: elixir rescue 
Elixir :: elixir enum each 
Elixir :: phoenix run test 
Scala :: quantification scalaire 
Scala :: scala predicate 
Scala :: how to tell what type a variable is scala 
Excel :: excel conditional formatting outside of range 
Excel :: excel and 
Perl :: perl mongodb conf location 
Pascal :: subrange variables pascal 
Powershell :: takeown cmd 
Gdscript :: gdscript dictionary 
Cobol :: Cobol reverse a string 
Assembly :: Generate random strings only with uppercase letters and digits in Python 
Assembly :: get public ssh key 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: jquery unselect option 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =