Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Need Help Completing My System?

Asked by 4 years ago
Edited 4 years ago

lol ignore the title cuz the restrictions r annoying

So im trying to do something and im having a really hard time understanding this... soooo lets just say i do

local b = game.workspace.Baseplate
local p = Instance.new("Part",game.workspace)
p.Touched:Connect(function()
Print("KewlBoi")
end
----------------------Would i do?
b.Touched:Connect(function(hit)
if hit.Parent.Name = "ToolBoi" then
b.Transparency = 9
end
end

LIKE WHEN THE PART TOUCHES THE GROUND!! IF HIT!!! HELP PLZ

0
What I don't understand Koley_Moley -7 — 4y
0
Is your "ground" SmoothTerrain or Part?? NickIsANuke 217 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

If you are considering "Baseplate" as your ground, your code might be organized like this:

local ground = workspace:WaitForChild("Baseplate") --Define the baseplate. In case it isn't loaded just yet, we use :WaitForChild() to wait for it to catch up.
local part = Instance.new("Part", workspace) --Making a new part in the workspace.

part.Touched:Connect(function(hit) -- When it is touched, fire this. .Touched has a built-in parameter, which we define as "hit." This is the part that the other part has touched.
    if hit == baseplate then -- Checking if the part we touched is the baseplate.
        print("The part has touched the ground.") -- Add any code you want to run here!
    end
end)
Ad

Answer this question