local Activate: thread = nil
local OldColors = {}
local PartsWaiting = {}
local Tool: Tool = script.Parent
local TouchCooldown: boolean = false
local Touched: thread = nil
function UnwrappedTouched(Part: BasePart, ShouldWait: boolean)
if Part and TouchCooldown == false and Tool.Enabled == false and not PartsWaiting[Part] then
local OldColor: Color3 = Part.Color
TouchCooldown = true
PartsWaiting[Part] = true
table.insert(OldColors, {Object = Part, Color = Part.Color})
Part.Color = Color3.new(1, 0, 0)
Part.Orientation += Vector3.new(-90, 0, 0)
if ShouldWait == true then
task.wait(1 / 4)
Part.Color = OldColor
end
TouchCooldown = false
task.wait(1 / 4)
Part.Color = OldColor
end
end
function UnwrappedActivated()
if Tool.Enabled == true then
Tool.Enabled = false
for index, object in ipairs(Tool.Handle:GetTouchingParts()) do
Touched = coroutine.create(UnwrappedTouched)
coroutine.resume(Touched, object, false)
end
task.wait(10)
for index, object in ipairs(OldColors) do
object.Object.Color = object.Color
end
table.clear(PartsWaiting)
table.clear(OldColors)
Tool.Enabled = true
TouchCooldown = false
end
end
Tool.Handle.Touched:Connect(function(Part: BasePart)
Touched = coroutine.create(UnwrappedTouched)
coroutine.resume(Touched, Part, true)
end)
Tool.Activated:Connect(function()
Activate = coroutine.wrap(UnwrappedActivated)
Activate()
end)
What I have at the moment, the tool is activated and will rotate parts it touches. The rotated parts cannot be rotated again until the 10 seconds have passed.
bruh it rotated the whole baseplate!
I dont want that to happen!
look, when I activate the tool the ONLY THe Handle is rotated and not other parts, So The part that Touches The handle gets painted red. So it will only work 10 seconds, That is what i want
I donāt think anyone has mentioned this in this thread, but did you check to see if the Handle has the CanTouch property set to true? If itās not, touched events will not execute. Your code could be running perfectly fine, itās just not activating if CanTouch is false under the Handles Properties.
While a lot of people in this thread have been overcomplicating the script, it could have been working just fine from the get go. Thereās been many instances where I forget to check CanTouch or when Iām using a certain plugin in which disables CanTouch by default. You have to make sure all your properties are configured correctly.
You shouldnāt be writing full scripts for users on the forum, especially under this category.
All you have to do is point them in the right direction. Tell them what they need to do, give them code snippets for examples, and youāre set. If the OP is not competent enough to fulfill the task, they might have to read over the DevHub as well as watching Video tutorials if thatās their style.
To the OP,
If youāre making this system, I recommend using TweenService to rotate the handles Orientation property, not CFrame as that will affect position too.
Using bools would be most efficient in terms of making it so the paint tool doesnāt fire a million times in one second.