I have made a script, which I thought would work but it doesn't.
while script.Parent.Touched do workspace.TimeSwap.Dark.Color = Color3.fromRGB(255, 0, 0) workspace.TimeSwap.DarkVal.Value = true end
When the player touches the block, another block changes color and a value becomes true, but I don't want them to stay like that I just want them to work while the player is touching it.
script.Parent.Touched:Connect(function(hit) workspace.TimeSwap.Dark.Color = Color3.fromRGB(255, 0, 0) workspace.TimeSwap.DarkVal.Value = true end)
Touched
is an event. That's how you handle events
You can use TouchEnded to detect when a touch on a part stops and set the properties back to what they were before. There are examples of detecting Touched and TouchEnded events on the API reference that I have linked.