Hi! I want my block to be collidable when I press a button. How can I do that?
2>What’s the issue?
First thing I did was search on Youtube and searched a bit on Google as well. But, couldn’t find anything which is the usual. So I tried making a script myself, and this is the closest I got:
workspace.AppearBlock.CanCollide = true --(Also, I figured out this script when I searched something related to this topic on Google, which said BasePart.CanCollide)
Any help please?
GOAL: Have a button that allows you to step onto the the “AppearBlock” when you click the button with your cursor. If you don’t press the button, you can’t step on the “AppearBlock”.
I see you are new to scripting. While this can be achieved through many methods, imo ClickDetectors are the easiest way to start off. Check this article, I think it’ll be very useful!
Your script could look like this stub:
local clickable_part = -- reference to the part you want to click
local block = workspace.AppearBlock
clickable_part.ClickDetector.MouseClick:Connect(function()
block.CanCollide = true
end)
And that’s it! When someone clicks (or taps) the “clickable_part” button, the block will be collidable.
If you don’t want to rely on ClickDetectors or wish to dig deeper on user inputs, take a look at this tutorial.
It’s supposed to be, if I press a button, a block should be able to be stepped on, which is the “AppearBlock”. The “clickable_part” is the button to make the part appear so I can step on it.