Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Need Help Completing My System?

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

2 comments

0

What I don't understand

0

Is your "ground" SmoothTerrain or Part??

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.