local CURTAINS = {
workspace.BlueCurtain
}
local ClickDetector = Instance.new("ClickDetector")
local isOpen = false
ClickDetector.Parent = script.Parent
ClickDetector.MouseClick:Connect(function()
for _, curtain in pairs(CURTAINS) do
for i = 1, 50 do
Curtain.CFrame = Curtain.CFrame + Vector3.new(0,0.2*(isOpen and -1 or 1),0)
wait()
end
end
isOpen = not IsOpen
end)
i cant get my stuff working im trying to make it so that if a player touches a lever the lever goes down and the curtain goes up 50 studs basically the lever moves along a thing called track
the lever goes down when the curtain goes up (pulley system or a pivot on a seesaw)
i want it to do something like CC2 thing where levers go down and i also want to be able to close my stage so it has to go down but i cant figure out this scripting
im trying to make it so that if a player touches a lever the lever goes down and…
But you’re using a ClickDetector. ClickDetectors detect when the BasePart they’re parented to is clicked by a player. If you actually want to respond to a part being touched by a player, you need to Connect a function to the .Touched event of the relevant BasePart. For example, you might have a Part named “ToggleTrigger”. In that case, you can do something when a player touches it like so:
function onToggleTriggerTouched(touchingPart)
local character = touchingPart.Parent --might not be a valid character
local player = game.Players:GetPlayerFromCharacter(character) --if it's a valid character, the touching player is returned
if player ~= nil then
--do something
end
end
toggleTrigger.Touched:Connect(onToggleTriggerTouched)
Okay, so one thing I’m noticing is that you’re using workspace.BlueCurtain to get the curtain, but the BlueCurtain part is actually in the same model as your opener lever.
for _, curtain in pairs(CURTAINS) do
for i = 1, 50 do
Curtain.CFrame = Curtain.CFrame + Vector3.new(0,0.2*(isOpen and -1 or 1),0)
wait()
end
end
In that loop you’re passing “curtain” as the value. But you are trying to change the CFrame of something called “Curtain” which is not mentioned in the script.
Try changing “Curtain” to “curtain” in that loop and see if it works.
Please see this video on how to debug your scripts. It is going to be much easier and faster for you to iterate by debugging stuff yourself for awhile before posting in the scripting support category.
In this case it looks like workspace.BlueCurtain should be workspace.Model.BlueCurtain. It is very likely that there is an error in the output window when you run the script in the original post that would allow you to figure out what is wrong with your script.