Search
 
SCRIPT & CODE EXAMPLE
 

LUA

if part is touched

--example if something is touched like a part. it is gonna do something to the humanoid

local part = script.Parent  --this is the part... put the script in the part


part.Touched:Connect(function(player)   --this is when the player touched the brick. we are also gonna name it player
	local hum = player.Parent:FindFirstChildWhichIsA("Humanoid") --here we gonna check the humanoid
	if hum then -- here we gonna check if it is a humanoid
		--code: example... you can change the health, walkspeed , jumpspeed and more
	end
end)
Comment

How to get a player if a part is touched

local Players = game:GetService("Players")
local TouchPart = workspace["Part"] -- assign a part to it

TouchPart.Touched:Connect(function(touched)
    if touched.Parent:IsA("Model") and touched.Parent:FindFirstChild("Humanoid") then
        local Player = Players:GetPlayerFromCharacter(touched.Parent)
        if Player then
            -- do something here
        end
    end
end)
Comment

PREVIOUS NEXT
Code Example
Lua :: luau how to make a kill brick 
Lua :: how to print hello in lua 
Lua :: how to stop a renderstepped loop in lua 
Lua :: roblox how to make debounce 
Lua :: roblox interpolate color 
Lua :: how to detect if part had children roblox 
Lua :: lua globals 
Lua :: roblox table.find 
Lua :: how to give yourself money in your roblox game 
Lua :: roblox rotate model 
Lua :: lua while loops 
Lua :: roblox luau random number 
Lua :: vector2 roblox 
Lua :: lua for loops 
Lua :: lua wait function 
Lua :: while loop in lua 
Lua :: run a function in lua 
Lua :: fivem get closest player 
Lua :: how to make a math text in lua 
Lua :: lua table of alphabet 
Matlab :: transfer function get num and den matlab 
Matlab :: matlab symbolic roots 
Matlab :: matlab app designer axes buttondownfcn 
Basic :: xolo themeforest 
Elixir :: elixir string to atom 
Elixir :: elixir enum chunk_every 
Scala :: scala split string to list 
Scala :: currying scala 
Excel :: google sheets countif current month 
Perl :: perl print array 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =