#Converyor Part/Moving Part
88 messages · Page 1 of 1 (latest)
yes please
what do you want me to do for you?
.
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
how can i explain...
-- 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
ok
and i think you willl understand
did it worked?
** You are now Level 3! **
okay so it works on a part
** You are now Level 1! **
but let me see if it works if i put the parent as a folder
ok
so i dont have to make the script for every part
wait
ok
ok
so you see here, i made the thing i want for the damage parts
so i wanna do the same thing for the converyors
you wrote this?
yes
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
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
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?
hmm lets see
oof you didnt understand
i didnt mean
bruh
wait
what?
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
English its not my first language and it is lol
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
** You are now Level 2! **
with the converyor script
like the one you did
it worked when i put it in each part
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
but it didnt when i wanted to put it in a whole folder not in every
yea this works for damage parts
atleast i think
ok
i just need it to work for converyors
or moving parts
idk how to call it
wait il try smth
sorry i dont know what else i can do
welp its okay, thanks for the help, and sorry for your time loss
its ok if you need something else tag me or send me dm
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
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