#Converyor Part/Moving Part

88 messages · Page 1 of 1 (latest)

merry mortar
#

hello

#

do you want me to wright you a script?

frozen geyser
#

yes please

merry mortar
frozen geyser
#

.

#

if you can do that

#

i just kinda need a script that will make a person move when they step on it

#

but i dont want to put the script in every part when i make a new part

#

so i want to make a folder and then assign the script to it

#

but it doesnt work when i try to do that

merry mortar
#

i am bit confused but...

#

tell me if this worked

frozen geyser
#

how can i explain...

merry mortar
#

-- Insert this script into a Script object in a folder containing your conveyor parts

-- Set the speed of the conveyor
local speed = 10 -- Change this value to adjust the speed of the conveyor

-- Define a function to move the player in the direction of the conveyor
local function movePlayer(player, conveyorPart)
local direction = conveyorPart.CFrame.LookVector
local humanoid = player.Character and player.Character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid:Move(direction * speed)
end
end

-- Connect to the Touched event of each conveyor part in the folder
for _, conveyorPart in ipairs(script.Parent:GetChildren()) do
conveyorPart.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
movePlayer(player, conveyorPart)
end
end)
end

frozen geyser
#

alr wait

#

if it doesnt il show you a photo

merry mortar
#

ok

frozen geyser
#

and i think you willl understand

merry mortar
#

did it worked?

proper vergeBOT
#

studio** You are now Level 3! **studio

frozen geyser
#

okay so it works on a part

proper vergeBOT
#

studio** You are now Level 1! **studio

frozen geyser
#

but let me see if it works if i put the parent as a folder

merry mortar
#

ok

frozen geyser
#

so i dont have to make the script for every part

merry mortar
#

it worked?

#

@frozen geyser

frozen geyser
#

wait

merry mortar
#

ok

frozen geyser
#

rip it doesnt work

#

wait il send smth

merry mortar
#

ok

frozen geyser
#

so you see here, i made the thing i want for the damage parts

#

so i wanna do the same thing for the converyors

merry mortar
#

you wrote this?

frozen geyser
#

yes

merry mortar
#

can you send it to me?

#

copy paste

frozen geyser
#

local DamagePartsFolder = game.Workspace.DamageParts

for _, DamagePart in pairs(DamagePartsFolder:GetChildren()) do
DamagePart.Touched:Connect(function(touchPart)
local humanoid = touchPart.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid.Health = humanoid.Health -5
end
end)
end

#

so i try to do the same thing as i did to make this work

#

but i doenst

#

local DamagePartsFolder = game.Workspace.DamageParts

for _, DamagePart in pairs(DamagePartsFolder:GetChildren()) do

so this doesnt work

merry mortar
#

wait

#

give me 2 minutes

frozen geyser
#

this is supposed to make it easier, bc i dont have to make a script for every part

#

i just need to make a for loop that loops thought the folder

#

and assigns the atributes

merry mortar
#

delete your script and paste this and tell me if now its working

#

-- Insert this script into a Script object in your game

-- Change this value to adjust the damage dealt to players
local damage = 5

-- Connect to the Touched event of each part in the DamageParts folder
local damagePartsFolder = game.Workspace.DamageParts
for _, damagePart in ipairs(damagePartsFolder:GetChildren()) do
if damagePart:IsA("BasePart") then
damagePart.Touched:Connect(function(touchPart)
local humanoid = touchPart.Parent:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid:TakeDamage(damage)
end
end)
end
end

#

@frozen geyser it worked?

frozen geyser
#

hmm lets see

frozen geyser
#

i didnt mean

#

bruh

#

wait

merry mortar
#

what?

frozen geyser
#

you did it for the damage parts right

#

well i that was an example

#

and i wanted to do the folder thingy for converyors

#

not redo the damage part bc its works

#

im really sorry if its confusing

merry mortar
frozen geyser
#

but all i want is to not have to make the same script for every part

#

but for a whole folder

#

so i can make new parts without having to paste the same script

#

so i wanna do that

proper vergeBOT
#

studio** You are now Level 2! **studio

frozen geyser
#

with the converyor script

#

like the one you did

#

it worked when i put it in each part

merry mortar
#

you mean something like this?

#

-- Insert this script into a Script object in your game

-- Change this value to adjust the damage dealt to players
local damage = 5

-- Define a function to handle the Touched event for each part in a folder
local function handlePartTouched(part)
part.Touched:Connect(function(touchPart)
local humanoid = touchPart.Parent:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid:TakeDamage(damage)
end
end)
end

-- Connect to the Touched event of each part in the DamageParts folder and its subfolders
local damagePartsFolder = game.Workspace.DamageParts
for _, descendant in ipairs(damagePartsFolder:GetDescendants()) do
if descendant:IsA("BasePart") then
handlePartTouched(descendant)
end
end

frozen geyser
#

but it didnt when i wanted to put it in a whole folder not in every

frozen geyser
#

atleast i think

merry mortar
#

ok

frozen geyser
#

i just need it to work for converyors

#

or moving parts

#

idk how to call it

#

wait il try smth

merry mortar
#

sorry i dont know what else i can do

frozen geyser
#

welp its okay, thanks for the help, and sorry for your time loss

merry mortar
frozen geyser
#

oh ok

#

ima try to fix it by myself

#

well it doesnt work but its alr i guess il just use the script for every converyor part i make

#

for now

faint burrow
#
local DamagePartFolder = workspace.DamageParts

for _, DamagePart  in pairs(DamagePartFolder:GetChildren()) do
         if DamagePart:IsA(“Part”) then
                     DamagePart.Touched:Connect(function(hit)
                           if hit.Parent:FindFirstChild(“Humanoid”) then
                                If hit ~= nil then 
                                   local hum = hit.Parent:FindFirstChild(“Humanoid”) 
                                  hum.Health -= 1
                             end
                           end
                      end)
           end
end