Im Making Balls Drop From the sky and rolling down, but i need them to disaper after they hit the back wall. I cant find out how to do it.
(BTW Its in roblox Studios)
Im Making Balls Drop From the sky and rolling down, but i need them to disaper after they hit the back wall. I cant find out how to do it.
(BTW Its in roblox Studios)
local Wall = script.Parent
Wall.Touched:Connect(function(hit)
if hit.Name == "Ball" then
hit:Destroy()
end
end)
You would have to use the touched event to detect when the ball hits the back wall. You might need to use a module script but idk much about them. Here's the code:
local ball = script.Parent
ball.Touched:Connect(function (hit)
if hit.Name == "Part name" then
ball.Transparency == 1
end
end)
Note: Each ball needs to have this script in it for this to work. The ball will only disappear when hitting the floor so not if it hits anything else like a player. If your back wall is made up of multiple parts you need to change hit.Name to hit.Parent.Name
Hope this helps!
Ok So Here The Step:
1. Make A Floor
Make a floor that will destroy the ball, name it "Floor".
2. Make A Script
Make a Script and place it inside the "Floor".
Copy and Paste This Script:
local Floor = script.Parent
Floor.Touched:Connect(function(Hit) -- Detect If Something Touch The Floor
if Hit.Name == "Balls" then -- Replace "Balls" with the name of your Falling Ball.
Hit:Destroy() -- Destroy The Ball
end
end)
Explanation
local Floor = script.Parent is the Floor
Floor.Touched will detect if something Touched the Floor, then will :Connect() it to a function
if Hit.Name == "Balls" if the Hit name was "Balls", then...
Hit:Destroy() It will :Destroy() the Hit
Hope It Helps!
This script detects when the ball touches another object and checks if it is the correct object.
local Part1 = game.Workspace.Part1 --Whatever the ball is
local Part2 = game.Workspace.Part2 --Whatever the ball is hitting
Part1.Touched:Connect(function(p) --Connected function
if p == Part2 then --Check if its the right part
--Code here
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
You forgot the "end" for the "if then" statement lol
lol
Wow I over thought things oof.